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

Mirror doesn't load annotations #5423

Closed
scabug opened this issue Jan 31, 2012 · 5 comments
Closed

Mirror doesn't load annotations #5423

scabug opened this issue Jan 31, 2012 · 5 comments
Assignees

Comments

@scabug
Copy link

scabug commented Jan 31, 2012

import java.lang.Class
import scala.reflect.mirror._
import scala.reflect.runtime.Mirror.ToolBox
import scala.reflect.Code

final class table extends StaticAnnotation
@table class A

object Test extends App{
  val c = new A
  val s = classToSymbol(classOf[A])

  assert( 1 == s.annotations.length ) // FAILS as length is 0 here

  val tree = Code.lift{c}.tree
  new ToolBox().typeCheck( tree )

  assert( 1 == s.annotations.length ) // SUCCEEDS
}
@scabug
Copy link
Author

scabug commented Jan 31, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5423?orig=1
Reporter: @xeno-by
Affected Versions: 2.10.0

@scabug
Copy link
Author

scabug commented Jan 31, 2012

@xeno-by said:
This stuff happens because dereferencing annotations does not trigger symbol completion.

@scabug
Copy link
Author

scabug commented Jan 31, 2012

@xeno-by said:
A workaround to this problem is to call whatever triggers the completion before inspecting annotations. E.g. a dummy "s.typeSig" does the trick.

@scabug
Copy link
Author

scabug commented Jan 31, 2012

@odersky said:
I propose to add a new method, getAnnotations, to AbsSymbol that does the forcing. I.e.

def getAnnotations = { initialize; annotations }

Then remove annotations from api.Symbol, and we should be good.

[I fear we can't do the forcing for all compiler symbols as that could introduce cycles. So it can be done only in reflection].

@scabug
Copy link
Author

scabug commented Feb 1, 2012

@xeno-by said:
Fixed by scala/scala@1eebc52

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