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

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

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

Comments

@scabug
Copy link

@scabug scabug commented Feb 17, 2012

(No description for SI-5498.)

@scabug

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 7, 2012

@scabug scabug closed this Aug 7, 2012
@scabug scabug added this to the 2.10.0-M6 milestone 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.