-
Notifications
You must be signed in to change notification settings - Fork 861
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle type annotations on method reference qualifiers
e.g. ``` Supplier<List<?>> a = @A(0x45) ArrayList::new; Supplier<List<?>> b = @A(0x46) ImmutableList::of; ``` The necessary logic is already there, but the start position information for the method reference doesn't include the leading type annotations, which was resulting in an assertion to fail. PiperOrigin-RevId: 577850593
- Loading branch information
Showing
3 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
core/src/test/resources/com/google/googlejavaformat/java/testdata/B308157568.input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class C { | ||
@A(0x14) | ||
int f(Object o) { | ||
@A(0x40) | ||
int local; | ||
try (@A(0x41) | ||
JarFile jarFile = new JarFile("hello.jar")) { | ||
} catch ( | ||
@A(0x42) | ||
IOException e) { | ||
} | ||
if (o instanceof @A(0x43) String) {} | ||
new @A(0x44) ArrayList<>(); | ||
Supplier<List<?>> a = @A(0x45) ArrayList::new; | ||
Supplier<List<?>> b = @A(0x46) ImmutableList::of; | ||
String s = (@A(0x47) String) o; | ||
List<?> xs = new ArrayList<@A(0x48) String>(); | ||
xs = ImmutableList.<@A(0x49) String>of(); | ||
Supplier<List<?>> c = ArrayList<@A(0x4A) String>::new; | ||
Supplier<List<?>> d = ImmutableList::<@A(0x4B) String>of; | ||
return 0; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
core/src/test/resources/com/google/googlejavaformat/java/testdata/B308157568.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class C { | ||
@A(0x14) | ||
int f(Object o) { | ||
@A(0x40) | ||
int local; | ||
try (@A(0x41) | ||
JarFile jarFile = new JarFile("hello.jar")) { | ||
} catch ( | ||
@A(0x42) | ||
IOException e) { | ||
} | ||
if (o instanceof @A(0x43) String) {} | ||
new @A(0x44) ArrayList<>(); | ||
Supplier<List<?>> a = @A(0x45) ArrayList::new; | ||
Supplier<List<?>> b = @A(0x46) ImmutableList::of; | ||
String s = (@A(0x47) String) o; | ||
List<?> xs = new ArrayList<@A(0x48) String>(); | ||
xs = ImmutableList.<@A(0x49) String>of(); | ||
Supplier<List<?>> c = ArrayList<@A(0x4A) String>::new; | ||
Supplier<List<?>> d = ImmutableList::<@A(0x4B) String>of; | ||
return 0; | ||
} | ||
} |