@@ -560,23 +560,23 @@ static Widget identity(Widget w) {
560560 // Even with a context-free template, the rewritten reference must carry both its type and
561561 // its binding to the freshly created local; otherwise downstream type-aware recipes break.
562562 spec -> spec .afterRecipe (cu -> {
563- List < J . Identifier > refs = new ArrayList <>();
563+ var refs = new ArrayList <J . Identifier >();
564564 new JavaIsoVisitor <Integer >() {
565565 @ Override
566566 public J .MethodInvocation visitMethodInvocation (J .MethodInvocation mi , Integer p ) {
567567 if ("super" .equals (mi .getSimpleName ())) {
568568 for (Expression a : mi .getArguments ()) {
569- if (a instanceof J .Identifier ) {
570- refs .add (( J . Identifier ) a );
569+ if (a instanceof J .Identifier identifier ) {
570+ refs .add (identifier );
571571 }
572572 }
573573 }
574574 return super .visitMethodInvocation (mi , p );
575575 }
576576 }.visit (cu , 0 );
577577 assertThat (refs ).hasSize (1 );
578- assertThat (refs .get ( 0 ).getType ()).as ("type" ).isNotNull ();
579- assertThat (refs .get ( 0 ).getFieldType ()).as ("fieldType (variable binding)" ).isNotNull ();
578+ assertThat (refs .getFirst ( ).getType ()).as ("type" ).isNotNull ();
579+ assertThat (refs .getFirst ( ).getFieldType ()).as ("fieldType (variable binding)" ).isNotNull ();
580580 })
581581 )
582582 );
@@ -644,19 +644,19 @@ static Derived makeDerived() {
644644 // source and is referenced nowhere else in this unit. A context-free template still resolves it
645645 // via the shared type cache, so the declared type must be a real FQ type, not Unknown.
646646 spec -> spec .afterRecipe (cu -> {
647- List < J . VariableDeclarations > decls = new ArrayList <>();
647+ var decls = new ArrayList <J . VariableDeclarations >();
648648 new JavaIsoVisitor <Integer >() {
649649 @ Override
650650 public J .VariableDeclarations visitVariableDeclarations (J .VariableDeclarations vd , Integer p ) {
651- if ("b" .equals (vd .getVariables ().get ( 0 ).getSimpleName ())) {
651+ if ("b" .equals (vd .getVariables ().getFirst ( ).getSimpleName ())) {
652652 decls .add (vd );
653653 }
654654 return super .visitVariableDeclarations (vd , p );
655655 }
656656 }.visit (cu , 0 );
657657 assertThat (decls ).hasSize (1 );
658- assertThat (decls .get ( 0 ).getTypeExpression ().getType ()).as ("declared type 'Base'" ).isNotNull ();
659- assertThat (TypeUtils .asFullyQualified (decls .get ( 0 ).getTypeExpression ().getType ()))
658+ assertThat (decls .getFirst ( ).getTypeExpression ().getType ()).as ("declared type 'Base'" ).isNotNull ();
659+ assertThat (TypeUtils .asFullyQualified (decls .getFirst ( ).getTypeExpression ().getType ()))
660660 .as ("declared type is a resolved FQ type, not Unknown" ).isNotNull ();
661661 })
662662 )
0 commit comments