summaryrefslogtreecommitdiff
path: root/test/files/neg/t0764b.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2014-02-11 11:39:51 -0800
committerPaul Phillips <paulp@improving.org>2014-02-11 11:42:55 -0800
commit36ca860b113372a80faa5b53bb3e817db680fc96 (patch)
tree1cd3cc1e6d9fca6ae9a6285a18c23b6c72a9892f /test/files/neg/t0764b.scala
parent64ad11b49bd7630d596e950953a5b15d3abf1689 (diff)
downloadscala-36ca860b113372a80faa5b53bb3e817db680fc96.tar.gz
scala-36ca860b113372a80faa5b53bb3e817db680fc96.tar.bz2
scala-36ca860b113372a80faa5b53bb3e817db680fc96.zip
Add a great test case.
Created to convince moors that certain code should compile, it wound up flushing out some quite nutty behavior. Some day this will compile rather than having an 11-failure checkfile.
Diffstat (limited to 'test/files/neg/t0764b.scala')
-rw-r--r--test/files/neg/t0764b.scala64
1 files changed, 64 insertions, 0 deletions
diff --git a/test/files/neg/t0764b.scala b/test/files/neg/t0764b.scala
new file mode 100644
index 0000000000..4ad5ecdc03
--- /dev/null
+++ b/test/files/neg/t0764b.scala
@@ -0,0 +1,64 @@
+/** Note that this should compile! It's a neg test to track the
+behavior. If you have broken this test by making it compile, that
+means you have fixed it and it should be moved to pos.
+**/
+
+// In all cases when calling "prepend" the receiver 'v'
+// has static type NodeAlias[A] or (equivalently) Node { type T = A }.
+// Since prepend explicitly returns the singleton type of the receiver,
+// the return type of prepend in all cases is "v.type", and so the call
+// to "new Main" can be parameterized with any of the following, in order
+// of decreasing specificity with a tie for second place:
+//
+// new Main[v.type](v.prepend)
+// new Main[NodeAlias[A]](v.prepend)
+// new Main[Node { type T = A }](v.prepend)
+// new Main(v.prepend)
+
+package p1 {
+ object t0764 {
+ type NodeAlias[A] = Node { type T = A }
+ trait Node { outer =>
+ type T <: Node
+ def prepend: Node { type T = outer.type } = ???
+ }
+
+ class Main1[A <: Node](v: NodeAlias[A]) {
+ private[this] def f1 = new Main1(v.prepend) // fail
+ private[this] def f2 = new Main1[NodeAlias[A]](v.prepend) // fail
+ private[this] def f3 = new Main1[Node { type T = A }](v.prepend) // fail
+ private[this] def f4 = new Main1[v.type](v.prepend) // ok
+ }
+
+ class Main2[A <: Node](v: Node { type T = A }) {
+ private[this] def f1 = new Main2(v.prepend) // fail
+ private[this] def f2 = new Main2[NodeAlias[A]](v.prepend) // fail
+ private[this] def f3 = new Main2[Node { type T = A }](v.prepend) // fail
+ private[this] def f4 = new Main2[v.type](v.prepend) // ok
+ }
+ }
+}
+
+package p2 {
+ object t0764 {
+ type NodeAlias[A] = Node { type T = A }
+ trait Node { outer =>
+ type T <: Node
+ def prepend: NodeAlias[outer.type] = ???
+ }
+
+ class Main1[A <: Node](v: NodeAlias[A]) {
+ private[this] def f1 = new Main1(v.prepend) // ok! <<========== WOT
+ private[this] def f2 = new Main1[NodeAlias[A]](v.prepend) // fail
+ private[this] def f3 = new Main1[Node { type T = A }](v.prepend) // fail
+ private[this] def f4 = new Main1[v.type](v.prepend) // ok
+ }
+
+ class Main2[A <: Node](v: Node { type T = A }) {
+ private[this] def f1 = new Main2(v.prepend) // fail
+ private[this] def f2 = new Main2[NodeAlias[A]](v.prepend) // fail
+ private[this] def f3 = new Main2[Node { type T = A }](v.prepend) // fail
+ private[this] def f4 = new Main2[v.type](v.prepend) // ok
+ }
+ }
+}