Skip to content

Commit 4214fb6

Browse files
cushonJavac Team
authored andcommitted
Update target Java version to 21
Also `getFirst()` and `getLast()` PiperOrigin-RevId: 831378131
1 parent 3899d6b commit 4214fb6

22 files changed

+65
-72
lines changed

java/com/google/turbine/binder/ConstEvaluator.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.google.common.base.Joiner;
2323
import com.google.common.collect.ImmutableList;
2424
import com.google.common.collect.ImmutableMap;
25-
import com.google.common.collect.Iterables;
2625
import com.google.turbine.binder.bound.EnumConstantValue;
2726
import com.google.turbine.binder.bound.TurbineAnnotationValue;
2827
import com.google.turbine.binder.bound.TurbineClassValue;
@@ -215,7 +214,7 @@ private ClassSymbol resolveNext(int position, ClassSymbol sym, Ident bit) {
215214
}
216215

217216
@Nullable FieldInfo resolveField(ConstVarName t) {
218-
Ident simpleName = t.name().get(0);
217+
Ident simpleName = t.name().getFirst();
219218
FieldInfo field = lexicalField(env, owner, simpleName);
220219
if (field != null) {
221220
return field;
@@ -267,7 +266,7 @@ private ClassSymbol resolveNext(int position, ClassSymbol sym, Ident bit) {
267266
return null;
268267
}
269268
}
270-
return Resolve.resolveField(env, origin, sym, Iterables.getLast(result.remaining()));
269+
return Resolve.resolveField(env, origin, sym, result.remaining().getLast());
271270
}
272271

273272
/** Search for constant variables in lexically enclosing scopes. */
@@ -1022,7 +1021,7 @@ AnnoInfo evaluateAnnotation(AnnoInfo info) {
10221021
LookupResult result = scope.lookup(new LookupKey(t.name()));
10231022
if (result == null) {
10241023
log.error(
1025-
t.name().get(0).position(), ErrorKind.CANNOT_RESOLVE, Joiner.on(".").join(t.name()));
1024+
t.name().getFirst().position(), ErrorKind.CANNOT_RESOLVE, Joiner.on(".").join(t.name()));
10261025
return null;
10271026
}
10281027
ClassSymbol sym = (ClassSymbol) result.sym();

java/com/google/turbine/binder/DisambiguateTypeAnnotations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ private static Type addAnnotationsToType(Type type, ImmutableList<AnnoInfo> extr
240240
}
241241
case CLASS_TY -> {
242242
ClassTy classTy = (ClassTy) type;
243-
SimpleClassTy base = classTy.classes().get(0);
243+
SimpleClassTy base = classTy.classes().getFirst();
244244
SimpleClassTy simple =
245245
SimpleClassTy.create(base.sym(), base.targs(), appendAnnotations(base.annos(), extra));
246246
yield Type.ClassTy.create(

java/com/google/turbine/binder/TypeBinder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.google.turbine.binder;
1818

19-
import static com.google.common.collect.Iterables.getLast;
2019
import static com.google.common.collect.Iterables.getOnlyElement;
2120
import static java.util.Objects.requireNonNull;
2221

@@ -530,7 +529,7 @@ private MethodInfo syntheticConstructor(
530529
int access = visibility.flag();
531530
access |= (base.access() & TurbineFlag.ACC_STRICT);
532531
if (!formals.isEmpty()
533-
&& (getLast(formals).access() & TurbineFlag.ACC_VARARGS) == TurbineFlag.ACC_VARARGS) {
532+
&& (formals.getLast().access() & TurbineFlag.ACC_VARARGS) == TurbineFlag.ACC_VARARGS) {
534533
access |= TurbineFlag.ACC_VARARGS;
535534
}
536535
return new MethodInfo(
@@ -934,7 +933,7 @@ private Type bindClassTy(CompoundScope scope, Tree.ClassTy t) {
934933
// resolve the prefix to a symbol
935934
LookupResult result = scope.lookup(new LookupKey(names));
936935
if (result == null || result.sym() == null) {
937-
log.error(names.get(0).position(), ErrorKind.CANNOT_RESOLVE, Joiner.on('.').join(names));
936+
log.error(names.getFirst().position(), ErrorKind.CANNOT_RESOLVE, Joiner.on('.').join(names));
938937
return Type.ErrorTy.create(names, bindTyArgs(scope, t.tyargs()));
939938
}
940939
Symbol sym = result.sym();

java/com/google/turbine/binder/bytecode/BytecodeBinder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.google.common.collect.ImmutableList;
2222
import com.google.common.collect.ImmutableListMultimap;
2323
import com.google.common.collect.ImmutableMap;
24-
import com.google.common.collect.Iterables;
2524
import com.google.turbine.binder.bound.EnumConstantValue;
2625
import com.google.turbine.binder.bound.ModuleInfo;
2726
import com.google.turbine.binder.bound.TurbineAnnotationValue;
@@ -88,7 +87,7 @@ private static Type.ClassTy bindClassTy(
8887
sb.append(sig.pkg()).append('/');
8988
}
9089
boolean first = true;
91-
Map<ClassSymbol, Sig.SimpleClassTySig> syms = new LinkedHashMap<>();
90+
LinkedHashMap<ClassSymbol, Sig.SimpleClassTySig> syms = new LinkedHashMap<>();
9291
for (Sig.SimpleClassTySig s : sig.classes()) {
9392
if (!first) {
9493
sb.append('$');
@@ -99,7 +98,7 @@ private static Type.ClassTy bindClassTy(
9998
first = false;
10099
}
101100
ArrayDeque<ClassSymbol> outers = new ArrayDeque<>();
102-
for (ClassSymbol curr = Iterables.getLast(syms.keySet());
101+
for (ClassSymbol curr = syms.sequencedKeySet().getLast();
103102
curr != null;
104103
curr = scope.outer(curr)) {
105104
outers.addFirst(curr);

java/com/google/turbine/binder/lookup/ImportIndex.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package com.google.turbine.binder.lookup;
1818

19-
import static com.google.common.collect.Iterables.getLast;
20-
2119
import com.google.common.base.Joiner;
2220
import com.google.common.base.Supplier;
2321
import com.google.common.base.Suppliers;
@@ -66,7 +64,7 @@ public static ImportIndex create(
6664
continue;
6765
}
6866
thunks.put(
69-
getLast(i.type()).value(),
67+
i.type().getLast().value(),
7068
Suppliers.memoize(
7169
new Supplier<@Nullable ImportScope>() {
7270
@Override
@@ -81,7 +79,7 @@ public static ImportIndex create(
8179
if (!i.stat() || i.wild()) {
8280
continue;
8381
}
84-
String last = getLast(i.type()).value();
82+
String last = i.type().getLast().value();
8583
thunks.putIfAbsent(
8684
last,
8785
Suppliers.memoize(

java/com/google/turbine/binder/lookup/LookupKey.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public LookupKey(ImmutableList<Ident> simpleNames) {
3535

3636
/** The first simple name in the qualified type name. */
3737
public Ident first() {
38-
return simpleNames.get(0);
38+
return simpleNames.getFirst();
3939
}
4040

4141
boolean hasNext() {

java/com/google/turbine/binder/lookup/MemberImportIndex.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package com.google.turbine.binder.lookup;
1818

19-
import static com.google.common.collect.Iterables.getLast;
20-
2119
import com.google.common.base.Supplier;
2220
import com.google.common.base.Suppliers;
2321
import com.google.common.collect.ImmutableList;
@@ -69,7 +67,7 @@ public MemberImportIndex(
6967
}));
7068
} else {
7169
cache.put(
72-
getLast(i.type()).value(),
70+
i.type().getLast().value(),
7371
Suppliers.memoize(
7472
new Supplier<@Nullable ClassSymbol>() {
7573
@Override

java/com/google/turbine/processing/TurbineAnnotationMirror.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.google.turbine.processing;
1818

1919
import static com.google.common.base.Preconditions.checkState;
20-
import static com.google.common.collect.Iterables.getLast;
2120
import static java.util.Objects.requireNonNull;
2221

2322
import com.google.common.base.Joiner;
@@ -86,7 +85,7 @@ public DeclaredType get() {
8685
if (anno.sym() == null) {
8786
return (ErrorType)
8887
factory.asTypeMirror(
89-
ErrorTy.create(getLast(anno.tree().name()).value(), ImmutableList.of()));
88+
ErrorTy.create(anno.tree().name().getLast().value(), ImmutableList.of()));
9089
}
9190
return (DeclaredType) factory.typeElement(anno.sym()).asType();
9291
}

java/com/google/turbine/processing/TurbineTypeMirror.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.google.turbine.processing;
1818

19-
import static com.google.common.collect.Iterables.getLast;
2019
import static java.util.Objects.requireNonNull;
2120

2221
import com.google.common.base.Joiner;
@@ -211,7 +210,7 @@ public TypeMirror getEnclosingType() {
211210
new Supplier<ImmutableList<TypeMirror>>() {
212211
@Override
213212
public ImmutableList<TypeMirror> get() {
214-
return factory.asTypeMirrors(getLast(type.classes()).targs());
213+
return factory.asTypeMirrors(type.classes().getLast().targs());
215214
}
216215
});
217216

@@ -236,7 +235,7 @@ public ClassTy type() {
236235

237236
@Override
238237
protected ImmutableList<AnnoInfo> annos() {
239-
return getLast(type.classes()).annos();
238+
return type.classes().getLast().annos();
240239
}
241240
}
242241

java/com/google/turbine/processing/TurbineTypes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private static boolean implicitObjectBound(ModelFactory factory, ImmutableList<T
205205
if (bounds.isEmpty()) {
206206
return true;
207207
}
208-
Type bound = bounds.get(0);
208+
Type bound = bounds.getFirst();
209209
return switch (bound.tyKind()) {
210210
case TY_VAR -> false;
211211
case CLASS_TY ->
@@ -441,7 +441,7 @@ private boolean isClassSubtype(ClassTy a, Type other, boolean strict) {
441441
}
442442
// perform repeated type substitution to get an instance of B with the type arguments
443443
// provided by A
444-
a = path.get(0);
444+
a = path.getFirst();
445445
for (ClassTy ty : path) {
446446
ImmutableMap<TyVarSymbol, Type> mapping = getMapping(ty);
447447
if (mapping == null) {

0 commit comments

Comments
 (0)