Navigation Menu

Skip to content

Commit

Permalink
SI-5756 correctly reifies local module classes
Browse files Browse the repository at this point in the history
Unlike module classes that are going to be pickled (which are reified
as `<their module reification>.moduleClass), module classes of
local modules need to be reified as symbol defs.

Otherwise we get a stack overflow:
1) Local modules are deemed to be free terms,
2) All free symbols are reified together with their type signature (so that they
   can be a) inspected by anyone interested, b) compiled at runtime),
3) Reifying a type signature of a module involves reifying its module class,
4) Reifying a module class involves reifying a module and calling its module class,
<ad infinitum>

This stack overflow doesn't happen for locatable modules, because they don't need
to have their type signatures reified (these signatures can later be loaded from
pickles if it becomes necessary).
  • Loading branch information
xeno-by committed Aug 8, 2012
1 parent 1183f06 commit 2ba6774
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/compiler/scala/reflect/reify/codegen/GenSymbols.scala
Expand Up @@ -36,7 +36,8 @@ trait GenSymbols {
else if (sym.isEmptyPackageClass)
mirrorMirrorSelect(nme.EmptyPackageClass)
else if (sym.isModuleClass)
Select(Select(reify(sym.sourceModule), nme.asModule), nme.moduleClass)
if (sym.sourceModule.isLocatable) Select(Select(reify(sym.sourceModule), nme.asModule), nme.moduleClass)
else reifySymDef(sym)
else if (sym.isPackage)
mirrorMirrorCall(nme.staticPackage, reify(sym.fullName))
else if (sym.isLocatable) {
Expand Down
6 changes: 6 additions & 0 deletions test/files/pos/t5756.scala
@@ -0,0 +1,6 @@
import scala.reflect.runtime.universe._

object Test extends App {
def tagme[T: TypeTag](x: T) = typeTag[T]
val foo = tagme{object Bar; Bar}
}
9 changes: 9 additions & 0 deletions test/files/pos/t6204-a.scala
@@ -0,0 +1,9 @@
import scala.reflect.runtime.universe._

object Bish {
def m {
object Bash {
typeOf[Option[_]]
}
}
}

0 comments on commit 2ba6774

Please sign in to comment.