summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/t0764b.check63
-rw-r--r--test/files/neg/t0764b.scala64
-rw-r--r--test/files/pos/t1786-counter.scala38
-rw-r--r--test/files/pos/t8209a.check0
-rw-r--r--test/files/pos/t8209a/Macros_1.scala17
-rw-r--r--test/files/pos/t8209a/Test_2.scala4
-rw-r--r--test/files/pos/t8209b.check0
-rw-r--r--test/files/pos/t8209b/Macros_1.scala17
-rw-r--r--test/files/pos/t8209b/Test_2.scala4
-rw-r--r--test/files/scalacheck/quasiquotes/PatternConstructionProps.scala6
-rw-r--r--test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala5
-rw-r--r--test/pending/pos/t1786.scala (renamed from test/files/pos/t1786.scala)8
-rw-r--r--test/pending/pos/t5459.scala (renamed from test/files/pos/t5459.scala)0
13 files changed, 225 insertions, 1 deletions
diff --git a/test/files/neg/t0764b.check b/test/files/neg/t0764b.check
new file mode 100644
index 0000000000..d74a9efbfe
--- /dev/null
+++ b/test/files/neg/t0764b.check
@@ -0,0 +1,63 @@
+t0764b.scala:27: error: type mismatch;
+ found : p1.t0764.Node{type T = p1.t0764.<refinement>.type}
+ required: p1.t0764.NodeAlias[p1.t0764.NodeAlias[A]]
+ (which expands to) p1.t0764.Node{type T = p1.t0764.Node{type T = A}}
+ private[this] def f1 = new Main1(v.prepend) // fail
+ ^
+t0764b.scala:28: error: type mismatch;
+ found : p1.t0764.Node{type T = p1.t0764.<refinement>.type}
+ required: p1.t0764.NodeAlias[p1.t0764.NodeAlias[A]]
+ (which expands to) p1.t0764.Node{type T = p1.t0764.Node{type T = A}}
+ private[this] def f2 = new Main1[NodeAlias[A]](v.prepend) // fail
+ ^
+t0764b.scala:29: error: type mismatch;
+ found : p1.t0764.Node{type T = p1.t0764.<refinement>.type}
+ required: p1.t0764.NodeAlias[p1.t0764.Node{type T = A}]
+ (which expands to) p1.t0764.Node{type T = p1.t0764.Node{type T = A}}
+ private[this] def f3 = new Main1[Node { type T = A }](v.prepend) // fail
+ ^
+t0764b.scala:34: error: type mismatch;
+ found : p1.t0764.Node{type T = p1.t0764.<refinement>.type}
+ required: p1.t0764.Node{type T = p1.t0764.Node{type T = A}}
+ private[this] def f1 = new Main2(v.prepend) // fail
+ ^
+t0764b.scala:35: error: type mismatch;
+ found : p1.t0764.Node{type T = p1.t0764.<refinement>.type}
+ required: p1.t0764.Node{type T = p1.t0764.NodeAlias[A]}
+ (which expands to) p1.t0764.Node{type T = p1.t0764.Node{type T = A}}
+ private[this] def f2 = new Main2[NodeAlias[A]](v.prepend) // fail
+ ^
+t0764b.scala:36: error: type mismatch;
+ found : p1.t0764.Node{type T = p1.t0764.<refinement>.type}
+ required: p1.t0764.Node{type T = p1.t0764.Node{type T = A}}
+ private[this] def f3 = new Main2[Node { type T = A }](v.prepend) // fail
+ ^
+t0764b.scala:52: error: type mismatch;
+ found : p2.t0764.Node{type T = p2.t0764.<refinement>.type}
+ required: p2.t0764.NodeAlias[p2.t0764.NodeAlias[A]]
+ (which expands to) p2.t0764.Node{type T = p2.t0764.Node{type T = A}}
+ private[this] def f2 = new Main1[NodeAlias[A]](v.prepend) // fail
+ ^
+t0764b.scala:53: error: type mismatch;
+ found : p2.t0764.Node{type T = p2.t0764.<refinement>.type}
+ required: p2.t0764.NodeAlias[p2.t0764.Node{type T = A}]
+ (which expands to) p2.t0764.Node{type T = p2.t0764.Node{type T = A}}
+ private[this] def f3 = new Main1[Node { type T = A }](v.prepend) // fail
+ ^
+t0764b.scala:58: error: type mismatch;
+ found : p2.t0764.Node{type T = p2.t0764.<refinement>.type}
+ required: p2.t0764.Node{type T = p2.t0764.Node{type T = A}}
+ private[this] def f1 = new Main2(v.prepend) // fail
+ ^
+t0764b.scala:59: error: type mismatch;
+ found : p2.t0764.Node{type T = p2.t0764.<refinement>.type}
+ required: p2.t0764.Node{type T = p2.t0764.NodeAlias[A]}
+ (which expands to) p2.t0764.Node{type T = p2.t0764.Node{type T = A}}
+ private[this] def f2 = new Main2[NodeAlias[A]](v.prepend) // fail
+ ^
+t0764b.scala:60: error: type mismatch;
+ found : p2.t0764.Node{type T = p2.t0764.<refinement>.type}
+ required: p2.t0764.Node{type T = p2.t0764.Node{type T = A}}
+ private[this] def f3 = new Main2[Node { type T = A }](v.prepend) // fail
+ ^
+11 errors found
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
+ }
+ }
+}
diff --git a/test/files/pos/t1786-counter.scala b/test/files/pos/t1786-counter.scala
new file mode 100644
index 0000000000..c1ad2c204f
--- /dev/null
+++ b/test/files/pos/t1786-counter.scala
@@ -0,0 +1,38 @@
+trait ShapeLevel
+
+object Fail {
+ abstract class ProductNodeShape[Level <: ShapeLevel, C, M <: C, U <: C, P <: C] extends Shape[Level, M, U, P] {
+ def copy(shapes: Seq[Shape[_, _, _, _]]): Shape[Level, _, _, _]
+ }
+
+ abstract class Shape[Level <: ShapeLevel, -Mixed_, Unpacked_, Packed_]
+
+ final class TupleShape[Level <: ShapeLevel, M <: Product, U <: Product, P <: Product](val shapes: Shape[_, _, _, _]*) extends ProductNodeShape[Level, Product, M, U, P] {
+ def copy(shapes: Seq[Shape[_, _, _, _]]): Shape[Level, _, _, _] = ???
+ }
+
+ trait ShapeLevel
+}
+
+object Ok {
+ abstract class Shape[Level <: ShapeLevel, -Mixed_, Unpacked_, Packed_]
+
+ abstract class ProductNodeShape[Level <: ShapeLevel, C, M <: C, U <: C, P <: C] extends Shape[Level, M, U, P] {
+ def copy(shapes: Seq[Shape[_, _, _, _]]): Shape[Level, _, _, _]
+ }
+
+ final class TupleShape[Level <: ShapeLevel, M <: Product, U <: Product, P <: Product](val shapes: Shape[_, _, _, _]*) extends ProductNodeShape[Level, Product, M, U, P] {
+ def copy(shapes: Seq[Shape[_, _, _, _]]): Shape[Level, _, _, _] = ???
+ }
+}
+
+// This is why we reverted the fix for SI-1786 -- see SI-6169 for a potential alternative that could be extended to cover this.
+// both objects type check on 2.10.3, but only Ok was accepted by 2.11 after the original fix to SI-1786.
+// Fail results in:
+/*
+t1786-counter.scala:10: error: class TupleShape needs to be abstract, since method copy in class ProductNodeShape of type (shapes: Seq[Fail.Shape[_, _, _, _]])Fail.Shape[Level, _, _, _] is not defined
+(Note that Seq[Fail.Shape[_, _, _, _]] does not match Seq[Fail.Shape[_ <: Fail.ShapeLevel, _, _, _]]: their type parameters differ)
+ final class TupleShape[Level <: ShapeLevel, M <: Product, U <: Product, P <: Product](val shapes: Shape[_, _, _, _]*) extends ProductNodeShape[Level, Product, M, U, P] {
+ ^
+one error found
+*/ \ No newline at end of file
diff --git a/test/files/pos/t8209a.check b/test/files/pos/t8209a.check
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/files/pos/t8209a.check
diff --git a/test/files/pos/t8209a/Macros_1.scala b/test/files/pos/t8209a/Macros_1.scala
new file mode 100644
index 0000000000..17014b4744
--- /dev/null
+++ b/test/files/pos/t8209a/Macros_1.scala
@@ -0,0 +1,17 @@
+import scala.language.experimental.macros
+import scala.language.implicitConversions
+import scala.reflect.macros.blackbox.Context
+
+class A
+object A { implicit def a2b(a: A): B = ??? }
+class B
+class C extends A
+
+object Macros {
+ def impl(c: Context) = {
+ import c.universe._
+ q"new C"
+ }
+
+ def foo: A = macro impl
+} \ No newline at end of file
diff --git a/test/files/pos/t8209a/Test_2.scala b/test/files/pos/t8209a/Test_2.scala
new file mode 100644
index 0000000000..e19d572f55
--- /dev/null
+++ b/test/files/pos/t8209a/Test_2.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ val a: A = Macros.foo
+ val b: B = Macros.foo
+} \ No newline at end of file
diff --git a/test/files/pos/t8209b.check b/test/files/pos/t8209b.check
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/files/pos/t8209b.check
diff --git a/test/files/pos/t8209b/Macros_1.scala b/test/files/pos/t8209b/Macros_1.scala
new file mode 100644
index 0000000000..705f7d630c
--- /dev/null
+++ b/test/files/pos/t8209b/Macros_1.scala
@@ -0,0 +1,17 @@
+import scala.language.experimental.macros
+import scala.language.implicitConversions
+import scala.reflect.macros.whitebox.Context
+
+class A
+object A { implicit def a2b(a: A): B = ??? }
+class B
+class C extends A
+
+object Macros {
+ def impl(c: Context) = {
+ import c.universe._
+ q"new C"
+ }
+
+ def foo: A = macro impl
+} \ No newline at end of file
diff --git a/test/files/pos/t8209b/Test_2.scala b/test/files/pos/t8209b/Test_2.scala
new file mode 100644
index 0000000000..e19d572f55
--- /dev/null
+++ b/test/files/pos/t8209b/Test_2.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ val a: A = Macros.foo
+ val b: B = Macros.foo
+} \ No newline at end of file
diff --git a/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala b/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala
index 582e915258..ca4c8609ac 100644
--- a/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala
@@ -29,4 +29,8 @@ object PatternConstructionProps extends QuasiquoteProperties("pattern constructi
property("splice into casedef") = forAll { (pat: Tree, cond: Tree, body: Tree) =>
cq"$pat if $cond => $body" ≈ CaseDef(pat, cond, body)
}
-} \ No newline at end of file
+
+ property("splice into alternative") = forAll { (first: Tree, rest: List[Tree]) =>
+ pq"$first | ..$rest" ≈ Alternative(first :: rest)
+ }
+}
diff --git a/test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala
index c8e66c7ef5..ad3266bcec 100644
--- a/test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala
@@ -36,4 +36,9 @@ object PatternDeconstructionProps extends QuasiquoteProperties("pattern deconstr
val cq"$pat0 if $cond0 => $body0" = cq"$pat if $cond => $body"
pat0 ≈ pat && cond0 ≈ cond && body0 ≈ body
}
+
+ property("extract alternative") = forAll { (first: Tree, rest: List[Tree]) =>
+ val pq"$first1 | ..$rest1" = pq"$first | ..$rest"
+ first1 ≈ first && rest1 ≈ rest
+ }
}
diff --git a/test/files/pos/t1786.scala b/test/pending/pos/t1786.scala
index 32d6c06f6e..6299eb9eae 100644
--- a/test/files/pos/t1786.scala
+++ b/test/pending/pos/t1786.scala
@@ -1,3 +1,11 @@
+/** This a consequence of the current type checking algorithm, where bounds are checked only after variables are instantiated.
+ * I believe this will change once we go to contraint-based type inference.
+ * Alternatively, we can pursue a more extensive fix to SI-6169
+ *
+ * The below code shows a compiler flaw in that the wildcard "_" as value for a bounded type parameter either
+ * breaks the boundary - as it result in Any - or doesn't evaluate to the boundary (as I'd hoped it to be).
+*/
+
class SomeClass(val intValue:Int)
class MyClass[T <: SomeClass](val myValue:T)
class Flooz[A >: Null <: SomeClass, T >: Null <: A](var value: T)
diff --git a/test/files/pos/t5459.scala b/test/pending/pos/t5459.scala
index 971e6f896d..971e6f896d 100644
--- a/test/files/pos/t5459.scala
+++ b/test/pending/pos/t5459.scala