Skip to content
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

Fix Java parsing of annotations on qualified types #21867

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
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ object JavaParsers {
}
while (in.token == DOT) {
in.nextToken()
annotations()
t = typeArgs(atSpan(t.span.start, in.offset)(typeSelect(t, ident())))
}
convertToTypeId(t)
Expand Down
8 changes: 8 additions & 0 deletions tests/pos/i21319/Foo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package app;

import java.util.Optional;
import lib.*;

public class Foo {
private [email protected] Optional<String> userId;
}
3 changes: 3 additions & 0 deletions tests/pos/i21319/Test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package app

class Test
17 changes: 17 additions & 0 deletions tests/pos/i21319/Valid.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package lib;

import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE_USE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

@Target({ METHOD, FIELD, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
@Documented
public @interface Valid {}
Loading