summaryrefslogtreecommitdiff
path: root/test/files
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 /test/files
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 'test/files')
-rw-r--r--test/files/pos/t7264/A_1.scala11
-rw-r--r--test/files/pos/t7264/B_2.scala7
2 files changed, 18 insertions, 0 deletions
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 */)
+}