diff options
author | Hubert Plociniczak <hubert.plociniczak@epfl.ch> | 2010-11-04 13:42:22 +0000 |
---|---|---|
committer | Hubert Plociniczak <hubert.plociniczak@epfl.ch> | 2010-11-04 13:42:22 +0000 |
commit | 29be721e25c761a4d58211d1bd698ee3e722fcb3 (patch) | |
tree | 897b1df77676edc50152e7e16ebc5b7aa70b7254 /src/compiler/scala/tools/nsc/typechecker/Namers.scala | |
parent | 379af580e2c8cf0ce5309fc0b31702f79e415abe (diff) | |
download | scala-29be721e25c761a4d58211d1bd698ee3e722fcb3.tar.gz scala-29be721e25c761a4d58211d1bd698ee3e722fcb3.tar.bz2 scala-29be721e25c761a4d58211d1bd698ee3e722fcb3.zip |
Some further changes related to r23434.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Namers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index e2098ee7d5..f8e69cf902 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -88,11 +88,12 @@ trait Namers { self: Analyzer => sym.flags = flags | lockedFlag if (sym.isModule && sym.moduleClass != NoSymbol) updatePosFlags(sym.moduleClass, pos, moduleClassFlags(flags)) - if (sym.owner.isPackageClass && - (sym.companionSymbol.rawInfo.isInstanceOf[loaders.SymbolLoader] || - sym.companionSymbol.rawInfo.isComplete && runId(sym.validTo) != currentRunId)) + var companion: Symbol = NoSymbol + if (sym.owner.isPackageClass && {companion = companionSymbolOf(sym, context); true} && + (companion.rawInfo.isInstanceOf[loaders.SymbolLoader] || + companion.rawInfo.isComplete && runId(sym.validTo) != currentRunId)) // pre-set linked symbol to NoType, in case it is not loaded together with this symbol. - sym.companionSymbol.setInfo(NoType) + companion.setInfo(NoType) sym } @@ -1362,7 +1363,7 @@ trait Namers { self: Analyzer => * Finds the companion module of a class symbol. Calling .companionModule * does not work for classes defined inside methods. */ - def companionModuleOf(clazz: Symbol, context: Context) = { + def companionModuleOf(clazz: Symbol, context: Context) = try { var res = clazz.companionModule if (res == NoSymbol) @@ -1374,9 +1375,8 @@ trait Namers { self: Analyzer => context.error(clazz.pos, e.getMessage) NoSymbol } - } - def companionClassOf(module: Symbol, context: Context) = { + def companionClassOf(module: Symbol, context: Context) = try { var res = module.companionClass if (res == NoSymbol) @@ -1387,7 +1387,11 @@ trait Namers { self: Analyzer => context.error(module.pos, e.getMessage) NoSymbol } - } + + def companionSymbolOf(sym: Symbol, context: Context) = + if (sym.isTerm) companionClassOf(sym, context) + else if (sym.isClass) companionModuleOf(sym, context) + else NoSymbol /** An explanatory note to be added to error messages * when there's a problem with abstract var defs */ |