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

Cannot get symbol for trait's implementation class #5176

Closed
scabug opened this issue Nov 10, 2011 · 2 comments
Closed

Cannot get symbol for trait's implementation class #5176

scabug opened this issue Nov 10, 2011 · 2 comments
Assignees

Comments

@scabug
Copy link

scabug commented Nov 10, 2011

This code says it all:

/** 
 * Tries to load a symbol for the `Foo$class` using Scala reflection.  
 * Since trait implementation classes do not get pickling information
 * symbol for them should be created using fallback mechanism
 * that exposes Java reflection information dressed up in
 * a Scala symbol.
 **/
object Test extends App {
  import scala.reflect.mirror
  val name = manifest[Foo].erasure.getName + "$class"
  val implClass = Class.forName(name)
  val symbol = mirror.classToSymbol(implClass)
  assert(symbol != mirror.NoSymbol)
}

trait Foo {
  def bar = 1
}

It fails at the moment for mysterious reason. Trying to investigate it.

@scabug
Copy link
Author

scabug commented Nov 10, 2011

@scabug
Copy link
Author

scabug commented Nov 10, 2011

Commit Message Bot (anonymous) said:
(grek in r25982) Allow to load $class classes using Scala reflection.

Tweaked implementation of invalidClassName method
to exclude *$class clasess from the set of invalid
names. It's not exactly clear what was the intent
of this method in first place so I'm not sure if
it's the best way to fix #5176. Added test-case
that covers this issue.

Fixes #5176. Review by odersky.

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

No branches or pull requests

2 participants