Skip to content

Commit 4e997d1

Browse files
authoredSep 27, 2024··
Tighten java annot value parsing (#21650)
2 parents eb5c3e8 + 07dce3f commit 4e997d1

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed
 

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ object JavaParsers {
369369
def annotation(): Option[Tree] = {
370370
def classOrId(): Tree =
371371
val id = qualId()
372-
if in.lookaheadToken == CLASS then
373-
in.nextToken()
372+
if in.token == DOT && in.lookaheadToken == CLASS then
373+
accept(DOT)
374374
accept(CLASS)
375375
TypeApply(
376376
Select(

‎tests/pos/i20026/J.java

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package p;
2+
3+
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
4+
class J { }

‎tests/pos/i20026/S.scala

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
class S

‎tests/pos/i20026/TestInstance.java

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package p;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Inherited;
5+
import java.lang.annotation.Retention;
6+
import java.lang.annotation.RetentionPolicy;
7+
import java.lang.annotation.Target;
8+
9+
@Target(ElementType.TYPE)
10+
@Retention(RetentionPolicy.RUNTIME)
11+
@Inherited
12+
public @interface TestInstance {
13+
enum Lifecycle { PER_CLASS, PER_METHOD; }
14+
Lifecycle value();
15+
}

0 commit comments

Comments
 (0)