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

Reflection: ModuleMirror.instance doesn't work for nested and inner modules #5498

Closed
scabug opened this issue Feb 17, 2012 · 3 comments
Closed
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Feb 17, 2012

(No description for SI-5498.)

@scabug
Copy link
Author

scabug commented Feb 17, 2012

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

@scabug
Copy link
Author

scabug commented Jun 18, 2012

@xeno-by said:

Welcome to Scala version 2.10.0-20120618-141100-416d58c599 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_33).
Type in expressions to have them evaluated.
Type :help for more information.

scala> trait ThirdParty { def invoke = println("right") }
trait WeatherIcon { def invoke = println("wrong") }
class MyClass {
    object objA extends ThirdParty
    object objB extends WeatherIcon
}
defined trait ThirdParty
defined trait WeatherIcon
defined class MyClass

scala> val stuff = typeOf[MyClass].members.filter(_.isValue).filter(_.typeSignature <:< typeOf[ThirdParty])
stuff @  de96c95: Iterable[reflect.runtime.universe.Symbol] = List(object objA)

scala> val objASymbol = stuff.head.asModuleSymbol
objASymbol @ 5da6725c: reflect.runtime.universe.ModuleSymbol = object objA

scala> cm.reflect(new MyClass).reflectModule(objASymbol)
res0 @ 5551685f: reflect.runtime.universe.ModuleMirror = scala.reflect.runtime.JavaMirrors$JavaMirror$JavaModuleMirror@5551685f

scala> res0.companion
res1 @ 3b362ca8: Option[reflect.runtime.universe.ClassMirror] = None

scala> res0.instance
java.lang.Error: inner and nested modules are not supported yet
        at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaModuleMirror.instance(JavaMirrors.scala:236)

@scabug
Copy link
Author

scabug commented Aug 7, 2012

@xeno-by said:
scala/scala#1079

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