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
Reflection on inner classes fails when outer object is not fully reflected before #7567
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7567?orig=1 |
Lars Hupel (larsrh) said: import scala.language.experimental.macros
import scala.reflect.macros.Context
def fooImpl[T: c.WeakTypeTag](c: Context): c.Expr[Unit] = { println(c.weakTypeOf[T].typeSymbol.asClass.companionSymbol); c.universe.reify {} }
def foo[T] = macro fooImpl[T]
scala> { case class Frob(x: Int); foo[Frob] }
<none> However: import scala.reflect.runtime.universe._
scala> { case class Frob(x: Int); weakTypeOf[Frob].typeSymbol.asClass.companionSymbol }
scala.ScalaReflectionException: free type Frob is not a class So, run-time and compile-time reflection disagree about whether |
@xeno-by said: |
not clear to me there's anything actionable here? |
In the following example, I am trying to get the instance of
Bar
(copy from Stackoverflow - http://stackoverflow.com/questions/17012294/recovering-a-singleton-instance-via-reflection-from-sealed-super-trait-when-typ/17016268#17016268 ):The companion symbol resolution in the
getModule
method fails here. If I uncomment the linefooC.companionSymbol.typeSignature
, it works as expected.The text was updated successfully, but these errors were encountered: