diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2012-12-10 11:55:04 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2012-12-10 11:55:04 -0800 |
commit | 2aac703b37aa26c928f2ca712afe6e1aeda604d2 (patch) | |
tree | 03a6ce27b15e1e5df3c149ad2d1ccb2bfc5c4cf4 | |
parent | 8c437b9b902cf7bb2b4bd2fcceca458b1196c544 (diff) | |
parent | 089cc9fee43a84ce4b93bf3c51b22136216bd831 (diff) | |
download | scala-2aac703b37aa26c928f2ca712afe6e1aeda604d2.tar.gz scala-2aac703b37aa26c928f2ca712afe6e1aeda604d2.tar.bz2 scala-2aac703b37aa26c928f2ca712afe6e1aeda604d2.zip |
Merge pull request #1670 from paulp/issue/6712
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 fbeb401c7d..3e1d3fdcc4 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 } +} |