Skip to content

Fix #11490: Support Java type annotation parsing #11525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ object JavaParsers {
}

def typ(): Tree =
annotations()
optArrayBrackets {
if (in.token == FINAL) in.nextToken()
if (in.token == IDENTIFIER) {
Expand Down Expand Up @@ -516,6 +517,7 @@ object JavaParsers {

def typeParam(flags: FlagSet): TypeDef =
atSpan(in.offset) {
annotations()
val name = identForType()
val hi = if (in.token == EXTENDS) { in.nextToken() ; bound() } else javaLangObject()
TypeDef(name, TypeBoundsTree(EmptyTree, hi)).withMods(Modifiers(flags))
Expand Down
7 changes: 7 additions & 0 deletions tests/pos/i11490/First.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package i11490;

import java.lang.annotation.*;

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE_USE, ElementType.TYPE_PARAMETER })
public @interface First {}
7 changes: 7 additions & 0 deletions tests/pos/i11490/Second.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package i11490;

import java.lang.annotation.*;

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE_USE, ElementType.TYPE_PARAMETER })
public @interface Second {}
7 changes: 7 additions & 0 deletions tests/pos/i11490/Use.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package i11490;

import java.util.List;

public class Use<@First T extends @Second List<@First @Second String>> {
public <@First S> @Second @First String method(@Second int a, @First @Second S b) { return ""; }
}