diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-06-02 17:56:19 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-06-05 11:46:13 +0200 |
commit | 86e6e9290a403ea852c33ca0901bdfc71bce1d67 (patch) | |
tree | 5ee6a26130b1ff894a1440193191b3f453bfd67d /src/compiler/scala/tools/nsc/typechecker/Namers.scala | |
parent | d70c0e344d420af1d8520b0a73109850f66c518c (diff) | |
download | scala-86e6e9290a403ea852c33ca0901bdfc71bce1d67.tar.gz scala-86e6e9290a403ea852c33ca0901bdfc71bce1d67.tar.bz2 scala-86e6e9290a403ea852c33ca0901bdfc71bce1d67.zip |
SI-7264 Initialize owner when searching for companion.
From ClassSymbol:
protected final def companionModule0: Symbol =
flatOwnerInfo.decl(name.toTermName).suchThat(sym => sym.isModuleNotMethod && (sym isCoDefinedWith this))
protected final def flatOwnerInfo: Type = {
if (needsFlatClasses)
info
owner.rawInfo
}
Note the call to `rawInfo`; in the enclosed test case, that gives
us back an uninitialized type for the module class of `Foo`, and
consequently we don't find the companion for `Foo.Values`.
This commit forces the initialization of the owning symbol if it
was compiled in a prior run.
In addition, it adds a special case to `Run#compiles` for early
initialized symbols, which start out in life with the wrong owner.
As best as I can see, that complexity stems from allowing early
initialized members *without* return types to be used as value arguments
to the super call, which in turn is needed to infer parent type arguments.
The situation is described a little further in existing comments of
`typedPrimaryConstrBody`.
This bug is essentially another case of SI-6976. See the comments in pull
request of that patch (https://github.com/scala/scala/pull/1910) for
commit archaeology that shows why we're reluctant to force the owner
info more broadly than is done in this commit.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Namers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 4683fca192..0305aab844 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -1686,8 +1686,13 @@ trait Namers extends MethodSynthesis { * call this method? */ def companionSymbolOf(original: Symbol, ctx: Context): Symbol = { + val owner = original.owner + // SI-7264 Force the info of owners from previous compilation runs. + // Doing this generally would trigger cycles; that's what we also + // use the lower-level scan through the current Context as a fall back. + if (!currentRun.compiles(owner)) owner.initialize original.companionSymbol orElse { - ctx.lookup(original.name.companionName, original.owner).suchThat(sym => + ctx.lookup(original.name.companionName, owner).suchThat(sym => (original.isTerm || sym.hasModuleFlag) && (sym isCoDefinedWith original) ) |