diff options
author | Paul Phillips <paulp@improving.org> | 2012-11-25 14:19:43 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-11-25 14:23:58 -0800 |
commit | 089cc9fee43a84ce4b93bf3c51b22136216bd831 (patch) | |
tree | 20fdff591d194bdd20a9e29c952cded52a1b7b2e | |
parent | 2a8291a3568abc848e79acaacd82e90932a77c8a (diff) | |
download | scala-089cc9fee43a84ce4b93bf3c51b22136216bd831.tar.gz scala-089cc9fee43a84ce4b93bf3c51b22136216bd831.tar.bz2 scala-089cc9fee43a84ce4b93bf3c51b22136216bd831.zip |
Fix for SI-6712, bug in object lifting.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 16 | ||||
-rw-r--r-- | test/files/pos/t6712.scala | 5 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index ee7805cb3d..599c0d3f14 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1264,13 +1264,15 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans val cdef = ClassDef(mods | MODULE, name.toTypeName, Nil, impl) setSymbol classSym setType NoType def findOrCreateModuleVar() = localTyper.typedPos(tree.pos) { - lazy val createModuleVar = gen.mkModuleVarDef(sym) - sym.enclClass.info.decl(nme.moduleVarName(sym.name.toTermName)) match { - // In case we are dealing with local symbol then we already have - // to correct error with forward reference - case NoSymbol => createModuleVar - case vsym => ValDef(vsym) - } + // See SI-5012, SI-6712. + val vsym = ( + if (sym.owner.isTerm) NoSymbol + else sym.enclClass.info.decl(nme.moduleVarName(sym.name.toTermName)) + ) + // In case we are dealing with local symbol then we already have + // to correct error with forward reference + if (vsym == NoSymbol) gen.mkModuleVarDef(sym) + else ValDef(vsym) } def createStaticModuleAccessor() = afterRefchecks { val method = ( diff --git a/test/files/pos/t6712.scala b/test/files/pos/t6712.scala new file mode 100644 index 0000000000..3c96eb14fb --- /dev/null +++ b/test/files/pos/t6712.scala @@ -0,0 +1,5 @@ +class H { + object O + + def foo() { object O } +} |