Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java parser incorrect tree #5699

Closed
scabug opened this issue Apr 23, 2012 · 2 comments
Closed

Java parser incorrect tree #5699

scabug opened this issue Apr 23, 2012 · 2 comments

Comments

@scabug
Copy link

scabug commented Apr 23, 2012

This bug blocks #5684.
There is a difference between compiling a java annotation and loading it from the class file and letting scalac parse it:

$ scalac -version
Scala compiler version 2.10.0-20120423-023931-3b61d19cdc -- Copyright 2002-2011, LAMP/EPFL

$ cat MyAnnotation.java
public @interface MyAnnotation { String value(); }

$ scalac -Ystop-after:typer -Xprint:typer MyAnnotation.java
[[syntax trees at end of typer]]// Scala source: MyAnnotation.java
package <empty> {
  object MyAnnotation extends  {
    def <init>() = _
  };
  class MyAnnotation extends scala.Annotation with _root_.java.lang.annotation.Annotation with scala.ClassfileAnnotation {
    def <init>(x$1: String) = _;
    def <init>() = _;
    def value(): String
  }
}

But then:

$ javac MyAnnotation.java

$ scala
Welcome to Scala version 2.10.0-20120423-023931-3b61d19cdc (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
Type in expressions to have them evaluated.
Type :help for more information.

scala> :power
** Power User mode enabled - BEEP WHIR GYVE **
** :phase has been set to 'typer'.          **
** scala.tools.nsc._ has been imported      **
** global._, definitions._ also imported    **
** Try  :help, :vals, power.<tab>           **

scala> ?[MyAnnotation].info

res0: $r.power.intp.global.Type = 
scala.annotation.Annotation
        with scala.annotation.ClassfileAnnotation
        with java.lang.annotation.Annotation {
  def value(): String
  def <init>(): MyAnnotation
}

So this leaves us with:

  • parsed MyAnnotation.java:
  def <init>(): MyAnnotation
  • loaded MyAnnotation.class:
  def <init>(x$1: String) = _; // this is the default constructor
def <init>() = _;
@scabug
Copy link
Author

scabug commented Apr 23, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5699?orig=1
Reporter: @VladUreche
Blocks #5684

@scabug
Copy link
Author

scabug commented Mar 15, 2013

@jrudolph said:
'parsed MyAnnotation.java' vs. 'loaded MyAnnotation.class' signatures: from the snippets above it seems it is exactly the other way round, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants