Skip to content

Commit

Permalink
Merge pull request #5 from scala/backport-lts-3.3-21650
Browse files Browse the repository at this point in the history
Backport "Tighten java annot value parsing" to LTS
  • Loading branch information
WojciechMazur authored Dec 6, 2024
2 parents c6a0f59 + 2358056 commit ffd7716
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ object JavaParsers {
def annotation(): Option[Tree] = {
def classOrId(): Tree =
val id = qualId()
if in.lookaheadToken == CLASS then
in.nextToken()
if in.token == DOT && in.lookaheadToken == CLASS then
accept(DOT)
accept(CLASS)
TypeApply(
Select(
Expand Down
4 changes: 4 additions & 0 deletions tests/pos/i20026/J.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package p;

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class J { }
1 change: 1 addition & 0 deletions tests/pos/i20026/S.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class S
15 changes: 15 additions & 0 deletions tests/pos/i20026/TestInstance.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package p;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface TestInstance {
enum Lifecycle { PER_CLASS, PER_METHOD; }
Lifecycle value();
}

0 comments on commit ffd7716

Please sign in to comment.