diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-03-25 11:23:59 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-03-25 11:23:59 +0100 |
commit | 876590b2be42a77fc23e5c57fc155d5772265be7 (patch) | |
tree | 4c7ecb96786ddbcc5ef56619f831299229a1be5e /src | |
parent | daa77d15dd11f086ea578f05ab29fb18119ec02d (diff) | |
parent | 540963f5648f49ea73e1064b0d5185edb1f7884d (diff) | |
download | scala-876590b2be42a77fc23e5c57fc155d5772265be7.tar.gz scala-876590b2be42a77fc23e5c57fc155d5772265be7.tar.bz2 scala-876590b2be42a77fc23e5c57fc155d5772265be7.zip |
Merge pull request #3614 from retronym/ticket/8196
SI-8196 Runtime reflection robustness for STATIC impl details
Diffstat (limited to 'src')
-rw-r--r-- | src/reflect/scala/reflect/runtime/JavaMirrors.scala | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 6fdb238462..9c0781ca06 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -685,8 +685,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni module.moduleClass setInfo new ClassInfoType(List(), newScope, module.moduleClass) } - def enter(sym: Symbol, mods: Int) = - (if (jModifier.isStatic(mods)) module.moduleClass else clazz).info.decls enter sym + def enter(sym: Symbol, mods: Int) = followStatic(clazz, module, mods).info.decls enter sym def enterEmptyCtorIfNecessary(): Unit = { if (jclazz.getConstructors.isEmpty) @@ -733,8 +732,12 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni * If Java modifiers `mods` contain STATIC, return the module class * of the companion module of `clazz`, otherwise the class `clazz` itself. */ - private def followStatic(clazz: Symbol, mods: Int) = - if (jModifier.isStatic(mods)) clazz.companionModule.moduleClass else clazz + private def followStatic(clazz: Symbol, mods: Int): Symbol = followStatic(clazz, clazz.companionModule, mods) + + private def followStatic(clazz: Symbol, module: Symbol, mods: Int): Symbol = + // SI-8196 `orElse(clazz)` needed for implementation details of the backend, such as the static + // field containing the cache for structural calls. + if (jModifier.isStatic(mods)) module.moduleClass.orElse(clazz) else clazz /** Methods which need to be treated with care * because they either are getSimpleName or call getSimpleName: |