Skip to content

Fails to compile java code with a valid java annotation syntax. #21319

Closed
@msosnicki

Description

@msosnicki

Compiler version

3.3.4

Minimized code

https://github.com/msosnicki/scala-annotations-java-issue

Piece of code that contains errors:

public record AnnotatedRecord(
  @JsonProperty("userId")
  java.util.@jakarta.validation.Valid Optional<scalac.issues.@jakarta.validation.Valid UserId> userId) {};

The code in the repo compiles fine in presence of sbt compileOrder := CompileOrder.ScalaThenJava settings. If it's removed, it is not compiling anymore (same as in 2.13.14).

Output

[error] -- Error: /home/ssn/code/scala/scala-annotations-java/src/main/java/scalac/issues/AnnotatedRecord.java:7:12
[error] 7 |  java.util.@jakarta.validation.Valid Optional<scalac.issues.@jakarta.validation.Valid UserId> userId) {};
[error]   |            ^^^^
[error]   |            identifier expected but @ found.
[error] -- Error: /home/ssn/code/scala/scala-annotations-java/src/main/java/scalac/issues/AnnotatedRecord.java:8:0
[error] 8 |
[error]   |^^^^^^
[error]   |identifier expected but eof found.
[error] two errors found

Expectation

Code compiles

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions