Skip to content

Commit 9373ce6

Browse files
authored
Merge pull request #11525 from Kordyjan/jsr308
Fix #11490: Support Java type annotation parsing
2 parents 05e5eab + d7fa529 commit 9373ce6

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ object JavaParsers {
277277
}
278278

279279
def typ(): Tree =
280+
annotations()
280281
optArrayBrackets {
281282
if (in.token == FINAL) in.nextToken()
282283
if (in.token == IDENTIFIER) {
@@ -515,6 +516,7 @@ object JavaParsers {
515516

516517
def typeParam(flags: FlagSet): TypeDef =
517518
atSpan(in.offset) {
519+
annotations()
518520
val name = identForType()
519521
val hi = if (in.token == EXTENDS) { in.nextToken() ; bound() } else javaLangObject()
520522
TypeDef(name, TypeBoundsTree(EmptyTree, hi)).withMods(Modifiers(flags))

tests/pos/i11490/First.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package i11490;
2+
3+
import java.lang.annotation.*;
4+
5+
@Retention(RetentionPolicy.RUNTIME)
6+
@Target({ ElementType.TYPE_USE, ElementType.TYPE_PARAMETER })
7+
public @interface First {}

tests/pos/i11490/Second.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package i11490;
2+
3+
import java.lang.annotation.*;
4+
5+
@Retention(RetentionPolicy.RUNTIME)
6+
@Target({ ElementType.TYPE_USE, ElementType.TYPE_PARAMETER })
7+
public @interface Second {}

tests/pos/i11490/Use.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package i11490;
2+
3+
import java.util.List;
4+
5+
public class Use<@First T extends @Second List<@First @Second String>> {
6+
public <@First S> @Second @First String method(@Second int a, @First @Second S b) { return ""; }
7+
}

0 commit comments

Comments
 (0)