summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
Diffstat (limited to 'test/files')
-rw-r--r--test/files/neg/t2775.check8
-rw-r--r--test/files/neg/t4568.check4
-rw-r--r--test/files/neg/t4568.scala13
-rw-r--r--test/files/neg/t750.check15
-rw-r--r--test/files/neg/t750/AO_1.java5
-rw-r--r--test/files/neg/t750/Test_2.scala6
-rw-r--r--test/files/neg/t750b.check15
-rw-r--r--test/files/neg/t750b/AO.java5
-rw-r--r--test/files/neg/t750b/Test.scala6
-rw-r--r--test/files/pos/gen-traversable-methods.scala20
-rw-r--r--test/files/run/t5629.check2
-rw-r--r--test/files/run/t5629.scala36
-rw-r--r--test/files/run/t5629b.check10
-rw-r--r--test/files/run/t5629b.scala41
14 files changed, 182 insertions, 4 deletions
diff --git a/test/files/neg/t2775.check b/test/files/neg/t2775.check
index f357221cd9..a1e950cf73 100644
--- a/test/files/neg/t2775.check
+++ b/test/files/neg/t2775.check
@@ -1,4 +1,4 @@
-t2775.scala:1: error: cannot find class tag for element type B.this.T
-trait B[S] { type T = S; val c = new Array[T](1) }
- ^
-one error found
+t2775.scala:1: error: cannot find array tag for element type B.this.T
+trait B[S] { type T = S; val c = new Array[T](1) }
+ ^
+one error found
diff --git a/test/files/neg/t4568.check b/test/files/neg/t4568.check
new file mode 100644
index 0000000000..f94d699486
--- /dev/null
+++ b/test/files/neg/t4568.check
@@ -0,0 +1,4 @@
+t4568.scala:8: error: recursive method isSubListOf needs result type
+ case h :: t => y.contains(h) && (t.isSubListOf(y.drop(y.indexOf(h) + 1)))
+ ^
+one error found
diff --git a/test/files/neg/t4568.scala b/test/files/neg/t4568.scala
new file mode 100644
index 0000000000..8067759262
--- /dev/null
+++ b/test/files/neg/t4568.scala
@@ -0,0 +1,13 @@
+object SubList {
+ implicit def sublistable[A](x: List[A]) = new SubListable(x)
+
+ class SubListable[A](x: List[A]) {
+ def isSubListOf(y: List[A]) = {
+ x match {
+ case Nil => true
+ case h :: t => y.contains(h) && (t.isSubListOf(y.drop(y.indexOf(h) + 1)))
+ }
+ }
+ }
+
+} \ No newline at end of file
diff --git a/test/files/neg/t750.check b/test/files/neg/t750.check
new file mode 100644
index 0000000000..c17ca334e6
--- /dev/null
+++ b/test/files/neg/t750.check
@@ -0,0 +1,15 @@
+Test_2.scala:4: error: type mismatch;
+ found : Array[Int]
+ required: Array[? with Object]
+Note: Int >: ? with Object, but class Array is invariant in type T.
+You may wish to investigate a wildcard type such as `_ >: ? with Object`. (SLS 3.2.10)
+ AO_1.f(a)
+ ^
+Test_2.scala:5: error: type mismatch;
+ found : Array[Int]
+ required: Array[Int]
+Note: Int >: Int, but class Array is invariant in type T.
+You may wish to investigate a wildcard type such as `_ >: Int`. (SLS 3.2.10)
+ AO_1.f[Int](a)
+ ^
+two errors found
diff --git a/test/files/neg/t750/AO_1.java b/test/files/neg/t750/AO_1.java
new file mode 100644
index 0000000000..4c7360ec6f
--- /dev/null
+++ b/test/files/neg/t750/AO_1.java
@@ -0,0 +1,5 @@
+public class AO_1 {
+ public static <T> void f(T[] ar0) {
+ System.out.println(ar0);
+ }
+} \ No newline at end of file
diff --git a/test/files/neg/t750/Test_2.scala b/test/files/neg/t750/Test_2.scala
new file mode 100644
index 0000000000..80977431c5
--- /dev/null
+++ b/test/files/neg/t750/Test_2.scala
@@ -0,0 +1,6 @@
+// t750
+object Test extends App {
+ val a = Array(1, 2, 3)
+ AO_1.f(a)
+ AO_1.f[Int](a)
+}
diff --git a/test/files/neg/t750b.check b/test/files/neg/t750b.check
new file mode 100644
index 0000000000..72a249191e
--- /dev/null
+++ b/test/files/neg/t750b.check
@@ -0,0 +1,15 @@
+Test.scala:4: error: type mismatch;
+ found : Array[Int]
+ required: Array[? with Object]
+Note: Int >: ? with Object, but class Array is invariant in type T.
+You may wish to investigate a wildcard type such as `_ >: ? with Object`. (SLS 3.2.10)
+ AO.f(a)
+ ^
+Test.scala:5: error: type mismatch;
+ found : Array[Int]
+ required: Array[Int]
+Note: Int >: Int, but class Array is invariant in type T.
+You may wish to investigate a wildcard type such as `_ >: Int`. (SLS 3.2.10)
+ AO.f[Int](a)
+ ^
+two errors found
diff --git a/test/files/neg/t750b/AO.java b/test/files/neg/t750b/AO.java
new file mode 100644
index 0000000000..060baf9a3c
--- /dev/null
+++ b/test/files/neg/t750b/AO.java
@@ -0,0 +1,5 @@
+public class AO {
+ public static <T> void f(T[] ar0) {
+ System.out.println(ar0);
+ }
+} \ No newline at end of file
diff --git a/test/files/neg/t750b/Test.scala b/test/files/neg/t750b/Test.scala
new file mode 100644
index 0000000000..5f792a7be8
--- /dev/null
+++ b/test/files/neg/t750b/Test.scala
@@ -0,0 +1,6 @@
+// t750
+object Test extends App {
+ val a = Array(1, 2, 3)
+ AO.f(a)
+ AO.f[Int](a)
+}
diff --git a/test/files/pos/gen-traversable-methods.scala b/test/files/pos/gen-traversable-methods.scala
new file mode 100644
index 0000000000..2604a09f11
--- /dev/null
+++ b/test/files/pos/gen-traversable-methods.scala
@@ -0,0 +1,20 @@
+
+
+
+import collection._
+
+
+
+object Test {
+
+ def main(args: Array[String]) {
+ val gen: GenTraversable[Int] = List(1, 2, 3)
+ gen.head
+ gen.headOption
+ gen.tail
+ gen.last
+ gen.lastOption
+ gen.init
+ }
+
+}
diff --git a/test/files/run/t5629.check b/test/files/run/t5629.check
new file mode 100644
index 0000000000..6a2d630f4e
--- /dev/null
+++ b/test/files/run/t5629.check
@@ -0,0 +1,2 @@
+int child got: 33
+any child got: 33
diff --git a/test/files/run/t5629.scala b/test/files/run/t5629.scala
new file mode 100644
index 0000000000..69feddd3a5
--- /dev/null
+++ b/test/files/run/t5629.scala
@@ -0,0 +1,36 @@
+
+
+
+import scala.{specialized => spec}
+
+
+
+trait GrandParent[@spec(Int) -A] {
+ def foo(a: A): Unit
+ def bar[B <: A](b: B): Unit = println("grandparent got: %s" format b)
+}
+
+
+trait Parent[@spec(Int) -A] extends GrandParent[A] {
+ def foo(a: A) = bar(a)
+}
+
+
+class IntChild extends Parent[Int] {
+ override def bar[B <: Int](b: B): Unit = println("int child got: %s" format b)
+}
+
+
+class AnyChild extends Parent[Any] {
+ override def bar[B <: Any](b: B): Unit = println("any child got: %s" format b)
+}
+
+
+object Test {
+
+ def main(args: Array[String]) {
+ new IntChild().foo(33)
+ new AnyChild().foo(33)
+ }
+
+}
diff --git a/test/files/run/t5629b.check b/test/files/run/t5629b.check
new file mode 100644
index 0000000000..1bc0248c3d
--- /dev/null
+++ b/test/files/run/t5629b.check
@@ -0,0 +1,10 @@
+=== pf(1):
+MySmartPF.apply entered...
+newPF.applyOrElse entered...
+default
+scala.MatchError: () (of class scala.runtime.BoxedUnit)
+=== pf(42):
+MySmartPF.apply entered...
+newPF.applyOrElse entered...
+ok
+=== done
diff --git a/test/files/run/t5629b.scala b/test/files/run/t5629b.scala
new file mode 100644
index 0000000000..6c908081b9
--- /dev/null
+++ b/test/files/run/t5629b.scala
@@ -0,0 +1,41 @@
+
+
+
+
+
+object Test extends App {
+
+ trait MyPF[@specialized(Int) -A] extends (A => Unit) {
+ def isDefinedAt(x: A): Boolean
+ def applyOrElse[A1 <: A](x: A1, default: A1 => Unit): Unit = {
+ println("MyPF.applyOrElse entered...")
+ if (isDefinedAt(x)) apply(x) else default(x)
+ }
+ }
+
+ trait MySmartPF[@specialized(Int) -A] extends MyPF[A] {
+ def apply(x: A): Unit = {
+ println("MySmartPF.apply entered...")
+ applyOrElse(x, { _: Any => throw new MatchError })
+ }
+ }
+
+ type T = Int
+ //type T = Any
+
+ def newPF(test: T): MyPF[T] = new MySmartPF[T] {
+ def isDefinedAt(x: T): Boolean = x != test
+ override def applyOrElse[A1 <: T](x: A1, default: A1 => Unit): Unit = {
+ println("newPF.applyOrElse entered...")
+ if (x != test) { println("ok"); () } else { println("default"); default(x) }
+ }
+ }
+
+ val pf = newPF(1)
+ println("=== pf(1):")
+ try { pf(1) } catch { case x => println(x) }
+ println("=== pf(42):")
+ pf(42)
+ println("=== done")
+
+}