summaryrefslogtreecommitdiff
path: root/test/files/pos/t3439.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-10-10 11:24:14 +1000
committerJason Zaugg <jzaugg@gmail.com>2014-10-10 15:57:01 +1000
commit91c34cedc9ee54244f6b49dda691cbe0be182037 (patch)
tree94a4e6a33b6d7966d83526d881cd008ce744cc66 /test/files/pos/t3439.scala
parent22233f40f641815fe7b9304bb386ee27c8422603 (diff)
downloadscala-91c34cedc9ee54244f6b49dda691cbe0be182037.tar.gz
scala-91c34cedc9ee54244f6b49dda691cbe0be182037.tar.bz2
scala-91c34cedc9ee54244f6b49dda691cbe0be182037.zip
SI-3439 Fix use of implicit constructor params in super call
When typechecking the primary constructor body, the symbols of constructor parameters of a class are owned by the class's owner. This is done make scoping work; you shouldn't be able to refer to class members in that position. However, other parts of the compiler weren't so happy about this arrangement. The enclosed test case shows that our checks for invalid, top-level implicits was spuriously triggered, and implicit search itself would fail. Furthermore, we had to hack `Run#compiles` to special case top-level early-initialized symbols. See SI-7264 / 86e6e9290. This commit: - introduces an intermediate local dummy term symbol which will act as the owner for constructor parameters and early initialized members - adds this to the `Run#symSource` map if it is top level - simplifies `Run#compiles` accordingly - tests this all in a top-level class, and one nested in another class.
Diffstat (limited to 'test/files/pos/t3439.scala')
-rw-r--r--test/files/pos/t3439.scala26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/files/pos/t3439.scala b/test/files/pos/t3439.scala
new file mode 100644
index 0000000000..ccc75cc4cf
--- /dev/null
+++ b/test/files/pos/t3439.scala
@@ -0,0 +1,26 @@
+class Base[M](i: Int)
+
+// was "implicit modifier not allowed on top level objects"
+class D1()(implicit i: Int) extends Base({println(i); 0})
+
+// what "no implicit value of type Int found"
+class D2()(implicit i: Int) extends Base(implicitly[Int])
+
+
+abstract class ParametricMessage[M: Manifest](msg: M) { def message = msg }
+case class ParametricMessage1[M: Manifest](msg: M, p1: Class[_]) extends ParametricMessage(msg)
+
+
+class Wrap {
+ class Base[M](i: Int)
+
+ // was "implicit modifier not allowed on top level objects"
+ class D1()(implicit i: Int) extends Base({println(i); 0})
+
+ // what "no implicit value of type Int found"
+ class D2()(implicit i: Int) extends Base(implicitly[Int])
+
+
+ abstract class ParametricMessage[M: Manifest](msg: M) { def message = msg }
+ case class ParametricMessage1[M: Manifest](msg: M, p1: Class[_]) extends ParametricMessage(msg)
+}