Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2274 from vigdorchik/ticket/si-5699
SI-5699 correct java parser for annotation defs.
- Loading branch information
Showing
3 changed files
with
36 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[[syntax trees at end of parser]] // annodef.java | ||
package <empty> { | ||
object MyAnnotation extends { | ||
def <init>() = _ | ||
}; | ||
class MyAnnotation extends scala.annotation.Annotation with _root_.java.lang.annotation.Annotation with scala.annotation.ClassfileAnnotation { | ||
def <init>() = _; | ||
def value(): String | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import scala.tools.partest.DirectTest | ||
import scala.tools.nsc.util.BatchSourceFile | ||
|
||
object Test extends DirectTest { | ||
// Java code | ||
override def code = """ | ||
|public @interface MyAnnotation { String value(); } | ||
""".stripMargin | ||
|
||
override def extraSettings: String = "-usejavacp -Ystop-after:typer -Xprint:parser" | ||
|
||
override def show(): Unit = { | ||
// redirect err to out, for logging | ||
val prevErr = System.err | ||
System.setErr(System.out) | ||
compile() | ||
System.setErr(prevErr) | ||
} | ||
|
||
override def newSources(sourceCodes: String*) = { | ||
assert(sourceCodes.size == 1) | ||
List(new BatchSourceFile("annodef.java", sourceCodes(0))) | ||
} | ||
} |