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
Labels

Comments

@scabug
Copy link

@scabug 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

This comment has been minimized.

Copy link
Author

@scabug 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

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jan 31, 2012

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

@scabug

This comment has been minimized.

Copy link
Author

@scabug 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

This comment has been minimized.

Copy link
Author

@scabug 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

This comment has been minimized.

Copy link
Author

@scabug scabug commented Feb 1, 2012

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

@scabug scabug closed this Feb 1, 2012
@scabug scabug added the reflection label Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.