diff options
author | Kurt Alfred Kluever <kak@google.com> | 2022-02-01 08:31:09 -0800 |
---|---|---|
committer | Javac Team <javac-team+copybara@google.com> | 2022-02-01 08:31:44 -0800 |
commit | 8efebf1e4b4a455965a16cc16767df914c336f0d (patch) | |
tree | 5dba84a6962b2e72b84db918da46ee96d8759642 | |
parent | 63846c1fb77df627f001b6bb32ef84ffd0c36394 (diff) | |
download | turbine-8efebf1e4b4a455965a16cc16767df914c336f0d.tar.gz |
Automatic code cleanup.
PiperOrigin-RevId: 425631296
15 files changed, 28 insertions, 26 deletions
diff --git a/java/com/google/turbine/binder/Binder.java b/java/com/google/turbine/binder/Binder.java index 2916a81..d2ce948 100644 --- a/java/com/google/turbine/binder/Binder.java +++ b/java/com/google/turbine/binder/Binder.java @@ -186,7 +186,7 @@ public final class Binder { } return new BindingResult( - result.build(), + result.buildOrThrow(), boundModules, classPathEnv, tli, @@ -293,7 +293,7 @@ public final class Binder { } }); } - return new LazyEnv<>(completers.build(), classPathEnv); + return new LazyEnv<>(completers.buildOrThrow(), classPathEnv); } private static Env<ClassSymbol, SourceTypeBoundClass> bindTypes( @@ -409,7 +409,8 @@ public final class Binder { // lazily evaluated fields in the current compilation unit with // constant fields in the classpath (which don't require evaluation). Env<FieldSymbol, Const.Value> constenv = - new LazyEnv<>(completers.build(), SimpleEnv.<FieldSymbol, Const.Value>builder().build()); + new LazyEnv<>( + completers.buildOrThrow(), SimpleEnv.<FieldSymbol, Const.Value>builder().build()); SimpleEnv.Builder<ClassSymbol, SourceTypeBoundClass> builder = SimpleEnv.builder(); for (ClassSymbol sym : syms) { diff --git a/java/com/google/turbine/binder/CanonicalTypeBinder.java b/java/com/google/turbine/binder/CanonicalTypeBinder.java index 944563f..5ff17bb 100644 --- a/java/com/google/turbine/binder/CanonicalTypeBinder.java +++ b/java/com/google/turbine/binder/CanonicalTypeBinder.java @@ -199,7 +199,7 @@ public final class CanonicalTypeBinder { (IntersectionTy) Canonicalize.canonicalize(source, position, env, sym, info.upperBound()); result.put(e.getKey(), new TyVarInfo(upperBound, /* lowerBound= */ null, info.annotations())); } - return result.build(); + return result.buildOrThrow(); } private static ImmutableList<Type> canonicalizeList( diff --git a/java/com/google/turbine/binder/CompUnitPreprocessor.java b/java/com/google/turbine/binder/CompUnitPreprocessor.java index 0e9f4e5..970dc4b 100644 --- a/java/com/google/turbine/binder/CompUnitPreprocessor.java +++ b/java/com/google/turbine/binder/CompUnitPreprocessor.java @@ -149,7 +149,7 @@ public final class CompUnitPreprocessor { types.add(new SourceBoundClass(sym, owner, children, access, decl)); } } - return result.build(); + return result.buildOrThrow(); } /** Desugars access flags for a class. */ diff --git a/java/com/google/turbine/binder/ConstBinder.java b/java/com/google/turbine/binder/ConstBinder.java index 3ba059f..29ae710 100644 --- a/java/com/google/turbine/binder/ConstBinder.java +++ b/java/com/google/turbine/binder/ConstBinder.java @@ -334,7 +334,7 @@ public class ConstBinder { /* lowerBound= */ null, constEvaluator.evaluateAnnotations(info.annotations()))); } - return result.build(); + return result.buildOrThrow(); } private Type bindType(Type type) { diff --git a/java/com/google/turbine/binder/HierarchyBinder.java b/java/com/google/turbine/binder/HierarchyBinder.java index 9a5f763..ac2c840 100644 --- a/java/com/google/turbine/binder/HierarchyBinder.java +++ b/java/com/google/turbine/binder/HierarchyBinder.java @@ -114,7 +114,8 @@ public class HierarchyBinder { typeParameters.put(p.name().value(), new TyVarSymbol(origin, p.name().value())); } - return new SourceHeaderBoundClass(base, superclass, interfaces.build(), typeParameters.build()); + return new SourceHeaderBoundClass( + base, superclass, interfaces.build(), typeParameters.buildOrThrow()); } /** diff --git a/java/com/google/turbine/binder/Processing.java b/java/com/google/turbine/binder/Processing.java index 555e691..a836fa7 100644 --- a/java/com/google/turbine/binder/Processing.java +++ b/java/com/google/turbine/binder/Processing.java @@ -272,7 +272,7 @@ public class Processing { for (Processor processor : processorInfo.processors()) { result.put(processor, SupportedAnnotationTypes.create(processor)); } - return result.build(); + return result.buildOrThrow(); } @AutoValue @@ -555,7 +555,7 @@ public class Processing { // requireNonNull is safe, barring bizarre processor implementations (e.g., anonymous class) result.put(requireNonNull(e.getKey().getCanonicalName()), e.getValue().elapsed()); } - return result.build(); + return result.buildOrThrow(); } } diff --git a/java/com/google/turbine/binder/TypeBinder.java b/java/com/google/turbine/binder/TypeBinder.java index e2011e2..92d2827 100644 --- a/java/com/google/turbine/binder/TypeBinder.java +++ b/java/com/google/turbine/binder/TypeBinder.java @@ -560,7 +560,7 @@ public class TypeBinder { new TyVarInfo( IntersectionTy.create(bounds.build()), /* lowerBound= */ null, annotations)); } - return result.build(); + return result.buildOrThrow(); } private List<MethodInfo> bindMethods( @@ -588,7 +588,7 @@ public class TypeBinder { for (Tree.TyParam pt : t.typarams()) { builder.put(pt.name().value(), new TyVarSymbol(sym, pt.name().value())); } - typeParameters = builder.build(); + typeParameters = builder.buildOrThrow(); } // type parameters can refer to each other in f-bounds, so update the scope first diff --git a/java/com/google/turbine/binder/bytecode/BytecodeBinder.java b/java/com/google/turbine/binder/bytecode/BytecodeBinder.java index af8a8a3..82f8a8c 100644 --- a/java/com/google/turbine/binder/bytecode/BytecodeBinder.java +++ b/java/com/google/turbine/binder/bytecode/BytecodeBinder.java @@ -137,7 +137,7 @@ public final class BytecodeBinder { for (Map.Entry<String, ElementValue> e : value.elementValuePairs().entrySet()) { values.put(e.getKey(), bindValue(e.getValue())); } - return new TurbineAnnotationValue(new AnnoInfo(null, sym, null, values.build())); + return new TurbineAnnotationValue(new AnnoInfo(null, sym, null, values.buildOrThrow())); } static ImmutableList<AnnoInfo> bindAnnotations(List<AnnotationInfo> input) { diff --git a/java/com/google/turbine/binder/bytecode/BytecodeBoundClass.java b/java/com/google/turbine/binder/bytecode/BytecodeBoundClass.java index 9be2dd1..cc97dcb 100644 --- a/java/com/google/turbine/binder/bytecode/BytecodeBoundClass.java +++ b/java/com/google/turbine/binder/bytecode/BytecodeBoundClass.java @@ -157,7 +157,7 @@ public class BytecodeBoundClass implements TypeBoundClass { result.put(inner.innerName(), new ClassSymbol(inner.innerClass())); } } - return result.build(); + return result.buildOrThrow(); } }); @@ -212,7 +212,7 @@ public class BytecodeBoundClass implements TypeBoundClass { for (Sig.TyParamSig p : csig.tyParams()) { result.put(p.name(), new TyVarSymbol(sym, p.name())); } - return result.build(); + return result.buildOrThrow(); } }); @@ -325,7 +325,7 @@ public class BytecodeBoundClass implements TypeBoundClass { // typeParameters() is constructed to guarantee the requireNonNull call is safe. tparams.put(requireNonNull(typeParameters().get(p.name())), bindTyParam(p, scope)); } - return tparams.build(); + return tparams.buildOrThrow(); } }); @@ -406,7 +406,7 @@ public class BytecodeBoundClass implements TypeBoundClass { for (Sig.TyParamSig p : sig.tyParams()) { result.put(p.name(), new TyVarSymbol(methodSymbol, p.name())); } - tyParams = result.build(); + tyParams = result.buildOrThrow(); } ImmutableMap<TyVarSymbol, TyVarInfo> tyParamTypes; @@ -417,7 +417,7 @@ public class BytecodeBoundClass implements TypeBoundClass { // tyParams is constructed to guarantee the requireNonNull call is safe. tparams.put(requireNonNull(tyParams.get(p.name())), bindTyParam(p, scope)); } - tyParamTypes = tparams.build(); + tyParamTypes = tparams.buildOrThrow(); } Function<String, TyVarSymbol> scope = makeScope(env, sym, tyParams); diff --git a/java/com/google/turbine/bytecode/ClassReader.java b/java/com/google/turbine/bytecode/ClassReader.java index 0f08fc3..740026a 100644 --- a/java/com/google/turbine/bytecode/ClassReader.java +++ b/java/com/google/turbine/bytecode/ClassReader.java @@ -335,7 +335,7 @@ public class ClassReader { // The runtimeVisible bit in AnnotationInfo is only used during lowering; earlier passes // read the meta-annotations. /* runtimeVisible= */ false, - values.build()); + values.buildOrThrow()); } private ElementValue readElementValue(ConstantPoolReader constantPool) { diff --git a/java/com/google/turbine/deps/Transitive.java b/java/com/google/turbine/deps/Transitive.java index fa3d475..2b8bd58 100644 --- a/java/com/google/turbine/deps/Transitive.java +++ b/java/com/google/turbine/deps/Transitive.java @@ -58,7 +58,7 @@ public final class Transitive { transitive.put( sym.binaryName(), ClassWriter.writeClass(trimClass(info.classFile(), info.jarFile()))); } - return transitive.build(); + return transitive.buildOrThrow(); } /** diff --git a/java/com/google/turbine/lower/Lower.java b/java/com/google/turbine/lower/Lower.java index ff7e13c..362316d 100644 --- a/java/com/google/turbine/lower/Lower.java +++ b/java/com/google/turbine/lower/Lower.java @@ -140,7 +140,7 @@ public class Lower { lower(module, env, symbols, majorVersion)); } } - return new Lowered(result.build(), ImmutableSet.copyOf(symbols)); + return new Lowered(result.buildOrThrow(), ImmutableSet.copyOf(symbols)); } /** Lowers a class to bytecode. */ @@ -637,7 +637,7 @@ public class Lower { for (Map.Entry<String, Const> entry : values.entrySet()) { result.put(entry.getKey(), annotationValue(entry.getValue())); } - return result.build(); + return result.buildOrThrow(); } private ElementValue annotationValue(Const value) { diff --git a/java/com/google/turbine/processing/TurbineAnnotationMirror.java b/java/com/google/turbine/processing/TurbineAnnotationMirror.java index 010fa6c..f99d211 100644 --- a/java/com/google/turbine/processing/TurbineAnnotationMirror.java +++ b/java/com/google/turbine/processing/TurbineAnnotationMirror.java @@ -106,7 +106,7 @@ class TurbineAnnotationMirror implements TurbineAnnotationValueMirror, Annotatio checkState(m.parameters().isEmpty()); result.put(m.name(), m); } - return result.build(); + return result.buildOrThrow(); } }); this.elementValues = @@ -126,7 +126,7 @@ class TurbineAnnotationMirror implements TurbineAnnotationValueMirror, Annotatio factory.executableElement(methodInfo.sym()), annotationValue(factory, value.getValue())); } - return result.build(); + return result.buildOrThrow(); } }); this.elementValuesWithDefaults = diff --git a/java/com/google/turbine/processing/TurbineTypes.java b/java/com/google/turbine/processing/TurbineTypes.java index 655b14b..4eb4c87 100644 --- a/java/com/google/turbine/processing/TurbineTypes.java +++ b/java/com/google/turbine/processing/TurbineTypes.java @@ -639,7 +639,7 @@ public class TurbineTypes implements Types { TyVarSymbol t = bx.next(); mapping.put(t, TyVar.create(s, ImmutableList.of())); } - return mapping.build(); + return mapping.buildOrThrow(); } /** @@ -660,7 +660,7 @@ public class TurbineTypes implements Types { } verify(!bx.hasNext()); } - return mapping.build(); + return mapping.buildOrThrow(); } @Override diff --git a/javatests/com/google/turbine/lower/LowerTest.java b/javatests/com/google/turbine/lower/LowerTest.java index c679228..6d3a6df 100644 --- a/javatests/com/google/turbine/lower/LowerTest.java +++ b/javatests/com/google/turbine/lower/LowerTest.java @@ -498,7 +498,7 @@ public class LowerTest { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); sources.forEach( (k, v) -> builder.put(k, v.replaceAll("import static b\\.B\\.nosuch\\..*;", ""))); - noImports = builder.build(); + noImports = builder.buildOrThrow(); } Map<String, byte[]> expected = IntegrationTestSupport.runJavac(noImports, ImmutableList.of()); |