Skip to content

Commit d7fa529

Browse files
committed
Support Java type annotation parsing
Direct port of scala/scala@7e57bcc included in scala/scala#5068
1 parent 5df688e commit d7fa529

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
@@ -278,6 +278,7 @@ object JavaParsers {
278278
}
279279

280280
def typ(): Tree =
281+
annotations()
281282
optArrayBrackets {
282283
if (in.token == FINAL) in.nextToken()
283284
if (in.token == IDENTIFIER) {
@@ -516,6 +517,7 @@ object JavaParsers {
516517

517518
def typeParam(flags: FlagSet): TypeDef =
518519
atSpan(in.offset) {
520+
annotations()
519521
val name = identForType()
520522
val hi = if (in.token == EXTENDS) { in.nextToken() ; bound() } else javaLangObject()
521523
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)