Skip to content

Commit ffd7716

Browse files
Merge pull request #5 from scala/backport-lts-3.3-21650
Backport "Tighten java annot value parsing" to LTS
2 parents c6a0f59 + 2358056 commit ffd7716

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
@@ -363,8 +363,8 @@ object JavaParsers {
363363
def annotation(): Option[Tree] = {
364364
def classOrId(): Tree =
365365
val id = qualId()
366-
if in.lookaheadToken == CLASS then
367-
in.nextToken()
366+
if in.token == DOT && in.lookaheadToken == CLASS then
367+
accept(DOT)
368368
accept(CLASS)
369369
TypeApply(
370370
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)