aboutsummaryrefslogtreecommitdiff
path: root/tests/neg
diff options
context:
space:
mode:
Diffstat (limited to 'tests/neg')
-rw-r--r--tests/neg/boundspropagation.scala2
-rw-r--r--tests/neg/existentials.scala61
-rw-r--r--tests/neg/hk-bounds.scala31
-rw-r--r--tests/neg/hk-variance.scala11
-rw-r--r--tests/neg/hklower.scala11
-rw-r--r--tests/neg/hklower2.scala4
-rw-r--r--tests/neg/i39.scala2
-rw-r--r--tests/neg/i50-volatile.scala4
-rw-r--r--tests/neg/kinds.scala18
-rw-r--r--tests/neg/named-params.scala37
-rw-r--r--tests/neg/ski.scala23
-rw-r--r--tests/neg/static-implements.scala11
-rw-r--r--tests/neg/static-no-companion.scala4
-rw-r--r--tests/neg/subtyping.scala2
-rw-r--r--tests/neg/t2994.scala6
-rw-r--r--tests/neg/t7278.scala8
-rw-r--r--tests/neg/tryPatternMatchError.scala35
-rw-r--r--tests/neg/zoo.scala12
18 files changed, 205 insertions, 77 deletions
diff --git a/tests/neg/boundspropagation.scala b/tests/neg/boundspropagation.scala
index b545b09da..dd4ebf513 100644
--- a/tests/neg/boundspropagation.scala
+++ b/tests/neg/boundspropagation.scala
@@ -40,5 +40,5 @@ object test4 {
}
class Test5 {
-"": ({ type U = this.type })#U // error // error
+"": ({ type U = this.type })#U // error
}
diff --git a/tests/neg/existentials.scala b/tests/neg/existentials.scala
new file mode 100644
index 000000000..4798504d9
--- /dev/null
+++ b/tests/neg/existentials.scala
@@ -0,0 +1,61 @@
+object TestList {
+
+ var x: ([X] -> List[List[X]])[_] = List(List(1)) // error: unreducible
+ var y: ([X] -> List[Seq[X]])[_] = List(List(1)) // error: unreducible
+
+ x = x
+ y = y
+ y = x
+
+ val h = x.head
+ val x1: List[_] = h
+
+ var z: List[_] = x
+
+}
+object TestSet {
+
+ var x: ([Y] -> Set[Set[Y]])[_] = Set(Set("a")) // error: unreducible
+ var y: ([Y] -> Set[Iterable[Y]])[_] = Set(Set("a")) // error: unreducible
+
+ x = x
+ y = y
+
+ val h = x.head
+ val h1: Set[_] = h
+
+ // val p = x.+ // infinite loop in implicit search
+
+ var z: Set[_] = x
+
+}
+class TestX {
+
+ class C[T](x: T) {
+ def get: T = x
+ def cmp: T => Boolean = (x == _)
+ }
+
+ val x: ([Y] -> C[C[Y]])[_] = new C(new C("a")) // error: unreducible
+
+ type CC[X] = C[C[X]]
+ val y: CC[_] = ??? // error: unreducible
+
+ type D[X] <: C[X]
+
+ type DD = [X] -> D[D[X]]
+ val z: DD[_] = ??? // error: unreducible
+
+ val g = x.get
+
+ val c = x.cmp
+}
+
+object Test6014 {
+ case class CC[T](key: T)
+ type Alias[T] = Seq[CC[T]]
+
+ def f(xs: Seq[CC[_]]) = xs map { case CC(x) => CC(x) } // ok
+ def g(xs: Alias[_]) = xs map { case CC(x) => CC(x) } // error: unreducible application
+}
+
diff --git a/tests/neg/hk-bounds.scala b/tests/neg/hk-bounds.scala
new file mode 100644
index 000000000..db6712d72
--- /dev/null
+++ b/tests/neg/hk-bounds.scala
@@ -0,0 +1,31 @@
+class Foo[A]
+class Bar[B]
+class Baz[C] extends Bar[C]
+
+object Test1 {
+ type Alias[F[X] <: Foo[X]] = F[Int]
+
+ val x: Alias[Bar] = new Bar[Int] // error: Type argument [X0] -> Bar[X0] does not conform to upper bound [X0] -> Foo[X0]
+
+ def foo[F[X] <: Foo[X]] = ()
+ foo[Bar] // error: Type argument [X0] -> Bar[X0] does not conform to upper bound [X0] -> Foo[X0]
+
+ def bar[B[X] >: Bar[X]] = ()
+ bar[Bar] // ok
+ bar[Baz] // // error: Type argument [X0] -> Baz[X0] does not conform to lower bound [X0] -> Bar[X0]
+ bar[Foo] // error: Type argument [X0] -> Foo[X0] does not conform to lower bound [X0] -> Bar[X0]
+
+ def baz[B[X] >: Baz[X]] = ()
+ baz[Bar] //ok
+ baz[Baz] //ok
+ baz[Foo] // error: Type argument [X0] -> Foo[X0] does not conform to lower bound [X0] -> Baz[X0]
+
+}
+object Test2 {
+ type Alias[F[X] <: Foo[X]] = F[Int]
+
+ def foo[M[_[_]], A[_]]: M[A] = null.asInstanceOf[M[A]]
+
+ val x = foo[Alias, Bar] // error: Type argument Test2.Alias does not conform to upper bound [X0 <: [X0] -> Any] -> Any
+
+}
diff --git a/tests/neg/hk-variance.scala b/tests/neg/hk-variance.scala
new file mode 100644
index 000000000..fec5cc366
--- /dev/null
+++ b/tests/neg/hk-variance.scala
@@ -0,0 +1,11 @@
+object Test {
+
+ def f[C[+X]] = ()
+
+ class D[X] {}
+
+ f[D] // error
+
+ def g[E[-Y]] = f[E] // error
+
+}
diff --git a/tests/neg/hklower.scala b/tests/neg/hklower.scala
deleted file mode 100644
index 5c1ba27ba..000000000
--- a/tests/neg/hklower.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-class Test { // error conflicting bounds
-
- type T[X] // OK
- type U[X] = T[X] // OK
-
- type V[X] >: T[X] // error
- type W[X] >: T[X] <: T[X] // error
-
- def f[C[X] >: T[X]]() = ??? // error
-
-}
diff --git a/tests/neg/hklower2.scala b/tests/neg/hklower2.scala
new file mode 100644
index 000000000..8268bf09f
--- /dev/null
+++ b/tests/neg/hklower2.scala
@@ -0,0 +1,4 @@
+class Test { // error: conflicting bounds
+ trait T[X]
+ type Z[X] >: String <: T[X]
+}
diff --git a/tests/neg/i39.scala b/tests/neg/i39.scala
index df53d9816..8a13a7d06 100644
--- a/tests/neg/i39.scala
+++ b/tests/neg/i39.scala
@@ -1,7 +1,7 @@
object i39neg {
trait B {
- type D <: { type T } // error
+ type D <: { type T }
def d: D
}
diff --git a/tests/neg/i50-volatile.scala b/tests/neg/i50-volatile.scala
index f6fa3466d..fcfc9592b 100644
--- a/tests/neg/i50-volatile.scala
+++ b/tests/neg/i50-volatile.scala
@@ -3,10 +3,10 @@ class Test {
class Inner
}
type A <: Base {
- type X = String // error
+ type X = String // old-error
}
type B <: {
- type X = Int // error
+ type X = Int // old-error
}
lazy val o: A & B = ???
diff --git a/tests/neg/kinds.scala b/tests/neg/kinds.scala
new file mode 100644
index 000000000..312c5d45e
--- /dev/null
+++ b/tests/neg/kinds.scala
@@ -0,0 +1,18 @@
+object Test {
+
+ class C[T]
+ class C2[T[X]]
+
+ class B
+
+ val x: C[C] = ??? // error: missing type parameter(s)
+ val y: C2[C] = ???
+
+ def f[T] = ???
+
+ def f2[T[X]] = ???
+
+ f[C] // error: missing type parameter(s)
+ f2[C]
+
+}
diff --git a/tests/neg/named-params.scala b/tests/neg/named-params.scala
deleted file mode 100644
index 5a2375b15..000000000
--- a/tests/neg/named-params.scala
+++ /dev/null
@@ -1,37 +0,0 @@
-package namedparams
-
-class C[type Elem, type Value](val elem: Elem) {
- def toVal: Elem = ???
-}
-
-abstract class D[type Elem, V](elem: Elem) extends C[Elem, V](elem)
-abstract class D2[Elem, V](elem: Elem) extends C[Elem, V](elem) // error
-abstract class D3[type Elem, V](x: V) extends C[V, V](x) // error
-abstract class D4[type Elem](elem: Elem) extends C[Elem, Elem] // error
-object Test {
- val c = new C[String, String]("A") {
- override def toVal = elem
- }
- val x: c.Elem = c.elem
-
- val c2: C { type Elem = String } = c
-
- val c3 = new C[Elem = String, Value = Int]("B")
- val c4 = new C[Elem = String]("C")
- val x2: c2.Elem = c2.elem
-
- val c5 = new C[Elem1 = String, Value0 = Int]("B") // error // error
-
- def d2[E, V](x: E) = new C[Elem = E, Value = V](x)
-
- val dup = d2[E = Int, V = String, E = Boolean](2) // error
- val z1 = d2[Elem = Int, Value = String](1) // error // error
- val z2 = d2[Value = String, Elem = Int](1) // error // error
- val z3 = d2[Elem = Int](1) // error
- val z4 = d2[Value = Int]("AAA") // error
- val z5 = d2[Elem = Int][Value = String](1) //error // error
-
-}
-
-
-
diff --git a/tests/neg/ski.scala b/tests/neg/ski.scala
index b192dc9e2..90a43039a 100644
--- a/tests/neg/ski.scala
+++ b/tests/neg/ski.scala
@@ -17,8 +17,8 @@ trait S2[x <: Term, y <: Term] extends Term {
type eval = S2[x, y]
}
trait S3[x <: Term, y <: Term, z <: Term] extends Term {
- type ap[v <: Term] = eval#ap[v] // error
- type eval = x#ap[z]#ap[y#ap[z]]#eval // error // error
+ type ap[v <: Term] = eval#ap[v] // error: not a legal path
+ type eval = x#ap[z]#ap[y#ap[z]]#eval // error: not a legal path // error: not a legal path
}
// The K combinator
@@ -31,8 +31,8 @@ trait K1[x <: Term] extends Term {
type eval = K1[x]
}
trait K2[x <: Term, y <: Term] extends Term {
- type ap[z <: Term] = eval#ap[z] // error
- type eval = x#eval // error
+ type ap[z <: Term] = eval#ap[z] // error: not a legal path
+ type eval = x#eval // error: not a legal path
}
// The I combinator
@@ -41,8 +41,8 @@ trait I extends Term {
type eval = I
}
trait I1[x <: Term] extends Term {
- type ap[y <: Term] = eval#ap[y] // error
- type eval = x#eval // error
+ type ap[y <: Term] = eval#ap[y] // error: not a legal path
+ type eval = x#eval // error: not a legal path
}
// Constants
@@ -64,9 +64,10 @@ case class Equals[A >: B <:B , B]()
object Test {
type T1 = Equals[Int, Int] // compiles fine
- type T2 = Equals[String, Int] // error
+ type T2 = Equals[String, Int] // error: Type argument String does not conform to upper bound Int
+
type T3 = Equals[I#ap[c]#eval, c]
- type T3a = Equals[I#ap[c]#eval, d] // error
+ type T3a = Equals[I#ap[c]#eval, d] // error: Type argument I1[c]#eval does not conform to upper bound d
// Ic -> c
type T4 = Equals[I#ap[c]#eval, c]
@@ -106,11 +107,11 @@ object Test {
type eval = A0
}
trait A1 extends Term {
- type ap[x <: Term] = x#ap[A0]#eval // error
+ type ap[x <: Term] = x#ap[A0]#eval // error: not a legal path
type eval = A1
}
trait A2 extends Term {
- type ap[x <: Term] = x#ap[A1]#eval // error
+ type ap[x <: Term] = x#ap[A1]#eval // error: not a legal path
type eval = A2
}
@@ -126,7 +127,7 @@ object Test {
type T15 = Equals[NN3#eval, c]
trait An extends Term {
- type ap[x <: Term] = x#ap[An]#eval // error
+ type ap[x <: Term] = x#ap[An]#eval // error: not a legal path
type eval = An
}
diff --git a/tests/neg/static-implements.scala b/tests/neg/static-implements.scala
new file mode 100644
index 000000000..8e8a8800c
--- /dev/null
+++ b/tests/neg/static-implements.scala
@@ -0,0 +1,11 @@
+import annotation.static
+
+abstract class A { def x: Int }
+
+class T
+object T extends A {
+ @static override val x = 10 // error: static methods cannot implement stuff
+ def main(args: Array[String]): Unit = {
+ println((this: A).x)
+ }
+}
diff --git a/tests/neg/static-no-companion.scala b/tests/neg/static-no-companion.scala
new file mode 100644
index 000000000..982dddf88
--- /dev/null
+++ b/tests/neg/static-no-companion.scala
@@ -0,0 +1,4 @@
+import annotation.static
+object T {
+ @static val foo = 10 // error: needs companion class
+}
diff --git a/tests/neg/subtyping.scala b/tests/neg/subtyping.scala
index 27cc0568e..351fa0ecd 100644
--- a/tests/neg/subtyping.scala
+++ b/tests/neg/subtyping.scala
@@ -8,7 +8,7 @@ object Test {
implicitly[B#X <:< A#X] // error: no implicit argument
}
def test2(): Unit = {
- val a : { type T; type U } = ??? // error // error
+ val a : { type T; type U } = ???
implicitly[a.T <:< a.U] // error: no implicit argument
}
}
diff --git a/tests/neg/t2994.scala b/tests/neg/t2994.scala
index 23a3b6a8b..e19397a3d 100644
--- a/tests/neg/t2994.scala
+++ b/tests/neg/t2994.scala
@@ -7,7 +7,7 @@ object Naturals {
type a[s[_ <: NAT] <: NAT, z <: NAT] = z
}
final class SUCC[n <: NAT] extends NAT {
- type a[s[_ <: NAT] <: NAT, z <: NAT] = s[n#a[s, z]] // old-error: not a legal path
+ type a[s[_ <: NAT] <: NAT, z <: NAT] = s[n#a[s, z]] // error: not a legal path
}
type _0 = ZERO
type _1 = SUCC[_0]
@@ -20,8 +20,8 @@ object Naturals {
// crashes scala-2.8.0 beta1
trait MUL[n <: NAT, m <: NAT] extends NAT {
- trait curry[n[_[_], _], s[_]] { type f[z <: NAT] = n[s, z] } // can't do double param lists: // error: `]' expected but `[` found. // error: wrong number of type arguments
- type a[s[_ <: NAT] <: NAT, z <: NAT] = n#a[curry[m#a, s]#f, z] // old-error: not a legal path // old-error: not a legal path
+ trait curry[n[_[_], _], s[_]] { type f[z <: NAT] = n[s, z] }
+ type a[s[_ <: NAT] <: NAT, z <: NAT] = n#a[curry[m#a, s]#f, z] // error: not a legal path // error: not a legal path // error: arg does not conform to bound // error: arg does not conform to bound
}
}
diff --git a/tests/neg/t7278.scala b/tests/neg/t7278.scala
index 7aafbb76f..643a3c858 100644
--- a/tests/neg/t7278.scala
+++ b/tests/neg/t7278.scala
@@ -13,8 +13,8 @@ object Test {
def fail1(): Unit = {
val b = new B
- var x1: EE[A] = null
- var x2: EE[B] = new b.E // old-error: found: B#E, required: A#E
+ var x1: EE[A] = null // error: Type argument A does not conform to upper bound EC
+ var x2: EE[B] = new b.E // error: Type argument B does not conform to upper bound EC
// x1 = x2 // gives a prior type error: B#E, required: A#E, masked to get at the real thing.
}
@@ -27,8 +27,8 @@ object Test {
}
*/
def fail3(): Unit = {
- var x1: EE[C] = 5
- var x2: EE[C & D] = ""
+ var x1: EE[C] = 5 // error: Type argument C does not conform to upper bound EC
+ var x2: EE[C & D] = "" // error: Type argument C & D does not conform to upper bound EC
x1 = x2
}
diff --git a/tests/neg/tryPatternMatchError.scala b/tests/neg/tryPatternMatchError.scala
new file mode 100644
index 000000000..fe12a6232
--- /dev/null
+++ b/tests/neg/tryPatternMatchError.scala
@@ -0,0 +1,35 @@
+import java.io.IOException
+import java.lang.NullPointerException
+import java.lang.IllegalArgumentException
+
+object IAE {
+ def unapply(e: Exception): Option[String] =
+ if (e.isInstanceOf[IllegalArgumentException]) Some(e.getMessage)
+ else None
+}
+
+object EX extends Exception
+
+trait ExceptionTrait extends Exception
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ var a: Int = 1
+ try {
+ throw new IllegalArgumentException()
+ } catch {
+ case e: IOException if e.getMessage == null =>
+ case e: NullPointerException =>
+ case e: IndexOutOfBoundsException =>
+ case _: NoSuchElementException =>
+ case _: ExceptionTrait =>
+ case _: NoSuchElementException if a <= 1 =>
+ case _: NullPointerException | _:IOException =>
+ case `a` => // This case should probably emmit an error
+ case e: Int => // error
+ case EX =>
+ case IAE(msg) =>
+ case e: IllegalArgumentException =>
+ }
+ }
+}
diff --git a/tests/neg/zoo.scala b/tests/neg/zoo.scala
index 3d9b77b72..19efcc1d7 100644
--- a/tests/neg/zoo.scala
+++ b/tests/neg/zoo.scala
@@ -1,23 +1,23 @@
object Test {
type Meat = {
- type IsMeat = Any // error
+ type IsMeat = Any
}
type Grass = {
- type IsGrass = Any // error
+ type IsGrass = Any
}
type Animal = {
- type Food // error
+ type Food
def eats(food: Food): Unit // error
def gets: Food // error
}
type Cow = {
- type IsMeat = Any // error
- type Food <: Grass // error
+ type IsMeat = Any
+ type Food <: Grass
def eats(food: Grass): Unit // error
def gets: Grass // error
}
type Lion = {
- type Food = Meat // error
+ type Food = Meat
def eats(food: Meat): Unit // error
def gets: Meat // error
}