summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
authorAntonio Cunei <antonio.cunei@epfl.ch>2010-05-26 14:14:12 +0000
committerAntonio Cunei <antonio.cunei@epfl.ch>2010-05-26 14:14:12 +0000
commite239d7fa5b9de5edffb06022c4cc5a9c105a51d3 (patch)
tree5aac86ae523db164174e39c900a5d2c5ad094075 /test/files/neg
parentc932ec58f9e6fc90c9497bb4cbfb09f2b398e7ea (diff)
downloadscala-e239d7fa5b9de5edffb06022c4cc5a9c105a51d3.tar.gz
scala-e239d7fa5b9de5edffb06022c4cc5a9c105a51d3.tar.bz2
scala-e239d7fa5b9de5edffb06022c4cc5a9c105a51d3.zip
svnmerge + tags
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/array-not-seq.check16
-rw-r--r--test/files/neg/array-not-seq.flags1
-rw-r--r--test/files/neg/array-not-seq.scala26
-rw-r--r--test/files/neg/bug3189.check7
-rw-r--r--test/files/neg/bug3189.scala3
-rw-r--r--test/files/neg/spec-overrides.check7
-rw-r--r--test/files/neg/spec-overrides.scala26
-rw-r--r--test/files/neg/t3453.check21
-rw-r--r--test/files/neg/t3453.scala66
9 files changed, 173 insertions, 0 deletions
diff --git a/test/files/neg/array-not-seq.check b/test/files/neg/array-not-seq.check
new file mode 100644
index 0000000000..bd72bb4e13
--- /dev/null
+++ b/test/files/neg/array-not-seq.check
@@ -0,0 +1,16 @@
+array-not-seq.scala:2: error: An Array will no longer match as Seq[_].
+ def f1(x: Any) = x.isInstanceOf[Seq[_]]
+ ^
+array-not-seq.scala:4: error: An Array will no longer match as Seq[_].
+ case _: Seq[_] => true
+ ^
+error: An Array will no longer match as Seq[_].
+array-not-seq.scala:16: error: An Array will no longer match as Seq[_].
+ case (Some(_: Seq[_]), Nil, _) => 1
+ ^
+error: An Array will no longer match as Seq[_].
+array-not-seq.scala:15: error: An Array will no longer match as Seq[_].
+ def f5(x1: Any, x2: Any, x3: AnyRef) = (x1, x2, x3) match {
+ ^
+error: An Array will no longer match as Seq[_].
+7 errors found
diff --git a/test/files/neg/array-not-seq.flags b/test/files/neg/array-not-seq.flags
new file mode 100644
index 0000000000..4e9f7e4a56
--- /dev/null
+++ b/test/files/neg/array-not-seq.flags
@@ -0,0 +1 @@
+-Xmigration -Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/array-not-seq.scala b/test/files/neg/array-not-seq.scala
new file mode 100644
index 0000000000..07a2898d88
--- /dev/null
+++ b/test/files/neg/array-not-seq.scala
@@ -0,0 +1,26 @@
+object Test {
+ def f1(x: Any) = x.isInstanceOf[Seq[_]]
+ def f2(x: Any) = x match {
+ case _: Seq[_] => true
+ case _ => false
+ }
+
+ def f3(x: Any) = x match {
+ case _: Array[_] => true
+ case _ => false
+ }
+
+ def f4(x: Any) = x.isInstanceOf[Traversable[_]]
+
+ def f5(x1: Any, x2: Any, x3: AnyRef) = (x1, x2, x3) match {
+ case (Some(_: Seq[_]), Nil, _) => 1
+ case (None, List(_: List[_], _), _) => 2
+ case _ => 3
+ }
+
+ def main(args: Array[String]): Unit = {
+ // println(f1(Array(1)))
+ // println(f2(Array(1)))
+ // println(f3(Array(1))
+ }
+}
diff --git a/test/files/neg/bug3189.check b/test/files/neg/bug3189.check
new file mode 100644
index 0000000000..520644fd43
--- /dev/null
+++ b/test/files/neg/bug3189.check
@@ -0,0 +1,7 @@
+bug3189.scala:2: error: illegal start of simple pattern
+ val Array(a,b*) = ("": Any)
+ ^
+bug3189.scala:3: error: ')' expected but '}' found.
+}
+^
+two errors found
diff --git a/test/files/neg/bug3189.scala b/test/files/neg/bug3189.scala
new file mode 100644
index 0000000000..4ea4bb7581
--- /dev/null
+++ b/test/files/neg/bug3189.scala
@@ -0,0 +1,3 @@
+object A {
+ val Array(a,b*) = ("": Any)
+} \ No newline at end of file
diff --git a/test/files/neg/spec-overrides.check b/test/files/neg/spec-overrides.check
new file mode 100644
index 0000000000..639186af40
--- /dev/null
+++ b/test/files/neg/spec-overrides.check
@@ -0,0 +1,7 @@
+spec-overrides.scala:8: error: Type parameter has to be specialized at least for the same types as in the overridden method. Missing types: Int
+ override def a[@specialized(Double) T](t: T): List[T] = Nil
+ ^
+spec-overrides.scala:12: error: Type parameter has to be specialized at least for the same types as in the overridden method. Missing types: Int
+ override def a[T](t: T): List[T] = Nil
+ ^
+two errors found
diff --git a/test/files/neg/spec-overrides.scala b/test/files/neg/spec-overrides.scala
new file mode 100644
index 0000000000..8c92b8ee25
--- /dev/null
+++ b/test/files/neg/spec-overrides.scala
@@ -0,0 +1,26 @@
+class P {
+ def a[@specialized(Int) T](t: T): List[T] = List(t)
+}
+class FX extends P {
+ override def a[@specialized(Int) T](t: T): List[T] = Nil
+}
+class FX1 extends P {
+ override def a[@specialized(Double) T](t: T): List[T] = Nil
+}
+
+class FX2 extends P {
+ override def a[T](t: T): List[T] = Nil
+}
+
+object Test extends Application {
+ val fx = new FX
+ val p = new P
+
+ println(fx.a(3))
+ println((fx: P).a(3))
+ println((fx: P).a(3.0))
+
+
+ // val d = new Derived[Int]
+ // println((d: Base[Int]).m(10))
+}
diff --git a/test/files/neg/t3453.check b/test/files/neg/t3453.check
new file mode 100644
index 0000000000..52c948128c
--- /dev/null
+++ b/test/files/neg/t3453.check
@@ -0,0 +1,21 @@
+t3453.scala:18: error: type mismatch;
+ found : A
+ required: B
+ new A
+ ^
+t3453.scala:36: error: type mismatch;
+ found : A
+ required: B
+ new A
+ ^
+t3453.scala:50: error: type mismatch;
+ found : A
+ required: B
+ new A
+ ^
+t3453.scala:64: error: type mismatch;
+ found : A
+ required: B
+ new A
+ ^
+four errors found
diff --git a/test/files/neg/t3453.scala b/test/files/neg/t3453.scala
new file mode 100644
index 0000000000..090b777151
--- /dev/null
+++ b/test/files/neg/t3453.scala
@@ -0,0 +1,66 @@
+// test shadowing of implicits by synonymous non-implicit symbols
+// whether they be inherited, imported (explicitly or using a wildcard) or defined directly
+class A
+class B
+
+trait S {
+ implicit def aToB(a: A): B = new B
+}
+
+class T1 extends S {
+ def x: B = {
+ val aToB = 3
+ // ok: doesn't compile, because aToB method requires 'T.this.' prefix
+ //aToB(new A)
+
+ // bug: compiles, using T.this.aToB,
+ // despite it not being accessible without a prefix
+ new A
+ }
+}
+
+object O {
+ implicit def aToB(a: A): B = new B
+}
+
+class T2a {
+ import O._
+
+ def x: B = {
+ val aToB = 3
+ // ok: doesn't compile, because aToB method requires 'T.this.' prefix
+ //aToB(new A)
+
+ // bug: compiles, using T.this.aToB,
+ // despite it not being accessible without a prefix
+ new A
+ }
+}
+
+class T2b {
+ import O.aToB
+
+ def x: B = {
+ val aToB = 3
+ // ok: doesn't compile, because aToB method requires 'T.this.' prefix
+ //aToB(new A)
+
+ // bug: compiles, using T.this.aToB,
+ // despite it not being accessible without a prefix
+ new A
+ }
+}
+
+class T3 {
+ implicit def aToB(a: A): B = new B
+
+ def x: B = {
+ val aToB = 3
+ // ok: doesn't compile, because aToB method requires 'T.this.' prefix
+ //aToB(new A)
+
+ // bug: compiles, using T.this.aToB,
+ // despite it not being accessible without a prefix
+ new A
+ }
+} \ No newline at end of file