From 86e6e9290a403ea852c33ca0901bdfc71bce1d67 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 2 Jun 2013 17:56:19 +0200 Subject: 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. --- test/files/pos/t7264/A_1.scala | 11 +++++++++++ test/files/pos/t7264/B_2.scala | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 test/files/pos/t7264/A_1.scala create mode 100644 test/files/pos/t7264/B_2.scala (limited to 'test/files/pos/t7264') diff --git a/test/files/pos/t7264/A_1.scala b/test/files/pos/t7264/A_1.scala new file mode 100644 index 0000000000..044d0110a2 --- /dev/null +++ b/test/files/pos/t7264/A_1.scala @@ -0,0 +1,11 @@ +object Foo { + object Values { + implicit def fromInt(x: Int): Values = ??? + } + trait Values +} +final class Foo(name: String) { + def bar(values: Foo.Values): Bar = ??? +} + +trait Bar diff --git a/test/files/pos/t7264/B_2.scala b/test/files/pos/t7264/B_2.scala new file mode 100644 index 0000000000..869c51481d --- /dev/null +++ b/test/files/pos/t7264/B_2.scala @@ -0,0 +1,7 @@ +object Test { + // if the following line is uncommented, things compile + // type X = Foo.Values + + + def foo(f: Foo) = f.bar(0 /* : Foo.Values */) +} -- cgit v1.2.3