-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement annotation parsing in JavaParsers.
This causes the java parser to get somewhat more complex, but allows for macros and compiler plugins to correctly inspect java-defined classes for annotations. Moved a few utility methods into {Parsers,Scanners}Common as well, so I can reuse them in the java ones. This involves a change to the t4788 tests, as SAnnotation now correctly has RetentionPolicy.SOURCE, and is therefore ignored by the check in BCodeHelpers#BCAnnotGen.shouldEmitAnnotation; also, ASM Textifier emits an // invisible marker now that CAnnotation has RetentionPolicy.CLASS. I'm not sure what the chances that anyone is relying upon this behavior are, but since it does the Right Thing for separate compilation runs, they probably should not be too disappointed. The new tests are run-tests not just pos-tests at the suggestion of retronym, to ensure that everything works the same at runtime as it does at compile time. As a matter of fact, it doesn't: the compile-time universe maintains ordering of annotation values in the tree, while the runtime universe uses java reflection to get at the values and therefore cannot know of their order. The test contains one exception for that. Review by densh, retronym Fixes scala/bug#8928 Co-authored-by: Jason Zaugg <jzaugg@gmail.com> Co-authored-by: Dale Wijnand <dale.wijnand@gmail.com>
- Loading branch information
1 parent
e1e2bfe
commit 44477d3
Showing
27 changed files
with
444 additions
and
43 deletions.
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
Some(@Ljava/lang/Deprecated;()) | ||
None | ||
Some(@LSAnnotation;()) | ||
Some(@LCAnnotation;()) | ||
None | ||
Some(@LCAnnotation;() // invisible) | ||
Some(@LRAnnotation;()) | ||
Some(@LAnnWithArgs_0$Ann;(value="literal") // invisible) | ||
Some(@LAnnWithArgs_0$Ann;(value="muk") // invisible) | ||
Some(@LAnnWithArgs_0$Ann;(value="mukja") // invisible) | ||
Some(@LAnnWithArgs_0$Ann;(value="mukja") // invisible) |
19 changes: 19 additions & 0 deletions
19
test/files/run/t4788-separate-compilation/AnnWithArgs_0.java
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,19 @@ | ||
public class AnnWithArgs_0 { | ||
public static @interface Ann { | ||
String value(); | ||
} | ||
|
||
@Ann("literal") | ||
public static int x1 = 1; | ||
|
||
@Ann(AnnWithArgs_0.strS) | ||
public static int x2 = 2; | ||
|
||
@Ann("muk" + "ja") | ||
public static int x3 = 3; | ||
|
||
@Ann(AnnWithArgs_0.strS + "ja") | ||
public static int x4 = 4; | ||
|
||
public static final String strS = "muk"; | ||
} |
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
Oops, something went wrong.