summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/Global.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-06-02 17:56:19 +0200
committerJason Zaugg <jzaugg@gmail.com>2013-06-05 11:46:13 +0200
commit86e6e9290a403ea852c33ca0901bdfc71bce1d67 (patch)
tree5ee6a26130b1ff894a1440193191b3f453bfd67d /src/compiler/scala/tools/nsc/Global.scala
parentd70c0e344d420af1d8520b0a73109850f66c518c (diff)
downloadscala-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/Global.scala')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index f1fccd6069..7068ab6f1e 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -1391,9 +1391,13 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
def registerPickle(sym: Symbol): Unit = ()
/** does this run compile given class, module, or case factory? */
+ // NOTE: Early initialized members temporarily typechecked before the enclosing class, see typedPrimaryConstrBody!
+ // Here we work around that wrinkle by claiming that a top-level, early-initialized member is compiled in
+ // *every* run. This approximation works because this method is exclusively called with `this` == `currentRun`.
def compiles(sym: Symbol): Boolean =
if (sym == NoSymbol) false
else if (symSource.isDefinedAt(sym)) true
+ else if (sym.isTopLevel && sym.isEarlyInitialized) true
else if (!sym.isTopLevel) compiles(sym.enclosingTopLevelClass)
else if (sym.isModuleClass) compiles(sym.sourceModule)
else false