From 06e7e342d1e27097df0b9d0b31a322fd1cf0a34e Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 25 Feb 2015 16:16:47 +1000 Subject: SI-9182 Fix runtime reflection with package object, overloads Eponymous modules and methods should be allowed to live in the same package scope. This can happen when using a module and and implicit class, or when defining the overloads manually. This commit tones back an assertion that was added for sanity checking runtime reflection thread safety to only fire when we are sure that neither the existing and current symbol of the given name are methods. --- src/reflect/scala/reflect/runtime/SymbolLoaders.scala | 3 ++- test/files/run/t9182.check | 3 +++ test/files/run/t9182.scala | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/files/run/t9182.check create mode 100644 test/files/run/t9182.scala diff --git a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala index 50ea8d9868..9ce6331e33 100644 --- a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala +++ b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala @@ -107,7 +107,8 @@ private[reflect] trait SymbolLoaders { self: SymbolTable => if (isCompilerUniverse) super.enter(sym) else { val existing = super.lookupEntry(sym.name) - assert(existing == null || existing.sym.isMethod, s"pkgClass = $pkgClass, sym = $sym, existing = $existing") + def eitherIsMethod(sym1: Symbol, sym2: Symbol) = sym1.isMethod || sym2.isMethod + assert(existing == null || eitherIsMethod(existing.sym, sym), s"pkgClass = $pkgClass, sym = $sym, existing = $existing") super.enter(sym) } } diff --git a/test/files/run/t9182.check b/test/files/run/t9182.check new file mode 100644 index 0000000000..80e8b6c558 --- /dev/null +++ b/test/files/run/t9182.check @@ -0,0 +1,3 @@ +constructor package +method A +object A diff --git a/test/files/run/t9182.scala b/test/files/run/t9182.scala new file mode 100644 index 0000000000..1768aa688e --- /dev/null +++ b/test/files/run/t9182.scala @@ -0,0 +1,12 @@ +// Main.scala +package object ops { + object A + def A(a: Any) = () +} + +object Test { + def main(args: Array[String]): Unit = { + val pack = scala.reflect.runtime.currentMirror.staticModule("ops.package") + println(pack.info.decls.toList.map(_.toString).sorted.mkString("\n")) + } +} -- cgit v1.2.3