File tree Expand file tree Collapse file tree
main/java/com/palantir/javaformat/java
test/resources/com/palantir/javaformat/java/testdata Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2684,18 +2684,29 @@ private void visitToDeclare(
26842684 Optional <String > trailing ,
26852685 Optional <BreakTag > annotationBreakForRecords ) {
26862686 sync (node );
2687+ Optional <TypeWithDims > typeWithDims ;
2688+ Tree type ;
2689+ if (node .getType () != null ) {
2690+ TypeWithDims extractedDims = DimensionHelpers .extractDims (node .getType (), SortedDims .YES );
2691+ typeWithDims = Optional .of (extractedDims );
2692+ type = extractedDims .node ;
2693+ } else {
2694+ // "var" and an untyped lambda parameter have no type tree
2695+ typeWithDims = Optional .empty ();
2696+ type = null ;
2697+ }
26872698 declareOne (
26882699 kind ,
26892700 annotationsDirection ,
26902701 Optional .of (node .getModifiers ()),
2691- node . getType () ,
2702+ type ,
26922703 node .getName (),
26932704 "" ,
26942705 equals ,
26952706 initializer ,
26962707 trailing ,
26972708 /* receiverExpression= */ Optional .empty (),
2698- /* typeWithDims= */ Optional . empty () ,
2709+ typeWithDims ,
26992710 annotationBreakForRecords );
27002711 }
27012712
Original file line number Diff line number Diff line change 1+ import java.lang.annotation.ElementType;
2+ import java.lang.annotation.Target;
3+
4+ @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
5+ @interface MyTypeAnno {}
6+
7+ public class GjfFailure {
8+ void m(int a @MyTypeAnno []) {}
9+ }
Original file line number Diff line number Diff line change 1+ import java.lang.annotation.ElementType;
2+ import java.lang.annotation.Target;
3+
4+ @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
5+ @interface MyTypeAnno {}
6+
7+ public class GjfFailure {
8+ void m(int a @MyTypeAnno []) {}
9+ }
You can’t perform that action at this time.
0 commit comments