summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/t5845.check5
-rw-r--r--test/files/neg/t997.check8
-rw-r--r--test/files/neg/t997.scala2
-rw-r--r--test/files/pos/t4881.scala31
-rw-r--r--test/files/run/t6090.scala6
-rw-r--r--test/files/run/t6111.check2
-rw-r--r--test/files/run/t6111.scala26
7 files changed, 68 insertions, 12 deletions
diff --git a/test/files/neg/t5845.check b/test/files/neg/t5845.check
index 8c6100d6de..c0b402fccb 100644
--- a/test/files/neg/t5845.check
+++ b/test/files/neg/t5845.check
@@ -1,7 +1,4 @@
-t5845.scala:9: error: value +++ is not a member of Int
- println(5 +++ 5)
- ^
t5845.scala:15: error: value +++ is not a member of Int
println(5 +++ 5)
^
-two errors found
+one error found
diff --git a/test/files/neg/t997.check b/test/files/neg/t997.check
index c9fe0de756..186095f44a 100644
--- a/test/files/neg/t997.check
+++ b/test/files/neg/t997.check
@@ -1,13 +1,7 @@
-t997.scala:7: error: wrong number of arguments for object Foo
-"x" match { case Foo(a) => Console.println(a) }
- ^
-t997.scala:7: error: not found: value a
-"x" match { case Foo(a) => Console.println(a) }
- ^
t997.scala:13: error: wrong number of arguments for object Foo
"x" match { case Foo(a, b, c) => Console.println((a,b,c)) }
^
t997.scala:13: error: not found: value a
"x" match { case Foo(a, b, c) => Console.println((a,b,c)) }
^
-four errors found
+two errors found
diff --git a/test/files/neg/t997.scala b/test/files/neg/t997.scala
index 42b46174d6..e8d10f4317 100644
--- a/test/files/neg/t997.scala
+++ b/test/files/neg/t997.scala
@@ -3,7 +3,7 @@ object Foo { def unapply(x : String) = Some(Pair(x, x)) }
object Test extends App {
-// Prints 'x'; ought not to compile (or maybe a should be the Pair?).
+// Prints '(x, x)'. Should compile as per SI-6111.
"x" match { case Foo(a) => Console.println(a) }
// Prints '(x,x)' as expected.
diff --git a/test/files/pos/t4881.scala b/test/files/pos/t4881.scala
new file mode 100644
index 0000000000..46cfad9793
--- /dev/null
+++ b/test/files/pos/t4881.scala
@@ -0,0 +1,31 @@
+class Contra[-T]
+trait A
+trait B extends A
+trait C extends B
+
+// test improved variance inference: first try formals to see in which variance positions the type param appears;
+// only when that fails to determine variance, look at result type
+object Test {
+ def contraLBUB[a >: C <: A](): Contra[a] = null
+ def contraLB[a >: C](): Contra[a] = null
+
+{
+ val x = contraLBUB() //inferred Contra[C] instead of Contra[A]
+ val x1: Contra[A] = x
+}
+
+{
+ val x = contraLB() //inferred Contra[C] instead of Contra[Any]
+ val x1: Contra[Any] = x
+}
+
+{
+ val x = contraLBUB // make sure it does the same thing as its ()-less counterpart
+ val x1: Contra[A] = x
+}
+
+{
+ val x = contraLB
+ val x1: Contra[Any] = x
+}
+}
diff --git a/test/files/run/t6090.scala b/test/files/run/t6090.scala
new file mode 100644
index 0000000000..e7dbb36a05
--- /dev/null
+++ b/test/files/run/t6090.scala
@@ -0,0 +1,6 @@
+class X { def ==(other: X) = true }
+class V(val x: X) extends AnyVal
+object Test extends {
+ def main(args: Array[String]) =
+ assert((new V(new X) == new V(new X)))
+}
diff --git a/test/files/run/t6111.check b/test/files/run/t6111.check
new file mode 100644
index 0000000000..7fd2e33526
--- /dev/null
+++ b/test/files/run/t6111.check
@@ -0,0 +1,2 @@
+(8,8)
+(x,x)
diff --git a/test/files/run/t6111.scala b/test/files/run/t6111.scala
new file mode 100644
index 0000000000..7cceea1d09
--- /dev/null
+++ b/test/files/run/t6111.scala
@@ -0,0 +1,26 @@
+// slightly overkill, but a good test case for implicit resolution in extractor calls,
+// along with the real fix: an extractor pattern with 1 sub-pattern should type check for all extractors
+// that return Option[T], whatever T (even if it's a tuple)
+object Foo {
+ def unapply[S, T](scrutinee: S)(implicit witness: FooHasType[S, T]): Option[T] = scrutinee match {
+ case i: Int => Some((i, i).asInstanceOf[T])
+ }
+}
+
+class FooHasType[S, T]
+object FooHasType {
+ implicit object int extends FooHasType[Int, (Int, Int)]
+}
+
+// resurrected from neg/t997
+object Foo997 { def unapply(x : String): Option[(String, String)] = Some((x, x)) }
+
+object Test extends App {
+ val x = 8
+ println(x match {
+ case Foo(p) => p // p should be a pair of Int
+ })
+
+ // Prints '(x, x)'
+ "x" match { case Foo997(a) => println(a) }
+} \ No newline at end of file