diff options
Diffstat (limited to 'test/files/neg')
37 files changed, 219 insertions, 69 deletions
diff --git a/test/files/neg/bug1210.check b/test/files/neg/bug1210.check deleted file mode 100644 index 4db920556f..0000000000 --- a/test/files/neg/bug1210.check +++ /dev/null @@ -1,7 +0,0 @@ -bug1210.scala:13: error: illegal cyclic reference involving type Settings - val v: List[selfType] = f[selfType]((x: selfType) => x.v) - ^ -bug1210.scala:24: error: illegal cyclic reference involving type Settings - f[selfType](_.g) - ^ -two errors found diff --git a/test/files/neg/bug1279a.check b/test/files/neg/bug1279a.check deleted file mode 100644 index edfd1fe871..0000000000 --- a/test/files/neg/bug1279a.check +++ /dev/null @@ -1,6 +0,0 @@ -bug1279a.scala:34: error: type mismatch; - found : first.selfType - required: M{type T <: this.T} - def all4Impl[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4Impl(first.next)) - ^ -one error found diff --git a/test/files/neg/bug1878.check b/test/files/neg/bug1878.check index 5484d675af..f760781fa0 100644 --- a/test/files/neg/bug1878.check +++ b/test/files/neg/bug1878.check @@ -1,10 +1,15 @@ bug1878.scala:3: error: _* may only come last val err1 = "" match { case Seq(f @ _*, ',') => f } ^ +bug1878.scala:3: error: scrutinee is incompatible with pattern type; + found : Seq[A] + required: java.lang.String + val err1 = "" match { case Seq(f @ _*, ',') => f } + ^ bug1878.scala:9: error: _* may only come last val List(List(_*, arg2), _) = List(List(1,2,3), List(4,5,6)) ^ bug1878.scala:13: error: _* may only come last case <p> { _* } </p> => ^ -three errors found +four errors found diff --git a/test/files/neg/bug2148.check b/test/files/neg/bug2148.check new file mode 100644 index 0000000000..22be424c39 --- /dev/null +++ b/test/files/neg/bug2148.check @@ -0,0 +1,4 @@ +bug2148.scala:9: error: type A is not a stable prefix + val b = new A with A#A1 + ^ +one error found diff --git a/test/files/neg/bug2148.scala b/test/files/neg/bug2148.scala new file mode 100644 index 0000000000..25788be84a --- /dev/null +++ b/test/files/neg/bug2148.scala @@ -0,0 +1,10 @@ +class A { + var i = 0 + trait A1 extends A { + i += 1 + } +} + +object Bob { + val b = new A with A#A1 +}
\ No newline at end of file diff --git a/test/files/neg/bug3123.check b/test/files/neg/bug3123.check new file mode 100644 index 0000000000..8f5319c9a3 --- /dev/null +++ b/test/files/neg/bug3123.check @@ -0,0 +1,4 @@ +bug3123.scala:3: error: object Int is not a value + t match { case Int => true } + ^ +one error found diff --git a/test/files/neg/bug3123.scala b/test/files/neg/bug3123.scala new file mode 100644 index 0000000000..667a1da918 --- /dev/null +++ b/test/files/neg/bug3123.scala @@ -0,0 +1,5 @@ +object NotAValue { + def test[T](t : T) { + t match { case Int => true } + } +} diff --git a/test/files/neg/bug414.check b/test/files/neg/bug414.check index c0f039ad26..ec23e26337 100644 --- a/test/files/neg/bug414.check +++ b/test/files/neg/bug414.check @@ -1,7 +1,3 @@ -bug414.scala:1: warning: case classes without a parameter list have been deprecated; -use either case objects or case classes with `()' as parameter list. -case class Empty[a] extends IntMap[a]; - ^ bug414.scala:5: error: pattern type is incompatible with expected type; found : object Empty required: IntMap[a] @@ -12,5 +8,4 @@ bug414.scala:7: error: type mismatch; required: a case _ => ^ -one warning found two errors found diff --git a/test/files/neg/bug961.check b/test/files/neg/bug961.check index 8b407d1d0c..439ed98675 100644 --- a/test/files/neg/bug961.check +++ b/test/files/neg/bug961.check @@ -1,9 +1,4 @@ -bug961.scala:4: warning: case classes without a parameter list have been deprecated; -use either case objects or case classes with `()' as parameter list. - private case class B_inner extends A - ^ bug961.scala:11: error: Temp.this.B of type object Temp.B does not take parameters B() match { ^ -one warning found one error found diff --git a/test/files/neg/bug961.scala b/test/files/neg/bug961.scala index 15309b96b4..088bddd7ee 100644 --- a/test/files/neg/bug961.scala +++ b/test/files/neg/bug961.scala @@ -1,7 +1,7 @@ -object Temp{ +object Temp { abstract class A - object B{ - private case class B_inner extends A + object B { + private case class B_inner() extends A def apply: A = B_inner() def unapply(a: A) = a match { case B_inner() => true diff --git a/test/files/neg/migration28.check b/test/files/neg/migration28.check new file mode 100644 index 0000000000..9e042a0f0b --- /dev/null +++ b/test/files/neg/migration28.check @@ -0,0 +1,9 @@ +migration28.scala:5: error: method ++= in class Stack has changed semantics: +Stack ++= now pushes arguments on the stack from left to right. + s ++= List(1,2,3) + ^ +migration28.scala:7: error: method foreach in class Stack has changed semantics: +Stack iterator and foreach now traverse in FIFO order. + s foreach (_ => ()) + ^ +two errors found diff --git a/test/files/neg/migration28.flags b/test/files/neg/migration28.flags new file mode 100644 index 0000000000..f7025d0226 --- /dev/null +++ b/test/files/neg/migration28.flags @@ -0,0 +1 @@ +-Yfatal-warnings -Xmigration diff --git a/test/files/neg/migration28.scala b/test/files/neg/migration28.scala new file mode 100644 index 0000000000..090b32d690 --- /dev/null +++ b/test/files/neg/migration28.scala @@ -0,0 +1,12 @@ +object Test { + import scala.collection.mutable._ + + val s = new Stack[Int] + s ++= List(1,2,3) + s map (_ + 1) + s foreach (_ => ()) + + def main(args: Array[String]): Unit = { + + } +} diff --git a/test/files/neg/multi-array.flags b/test/files/neg/multi-array.flags new file mode 100644 index 0000000000..c36e713ab8 --- /dev/null +++ b/test/files/neg/multi-array.flags @@ -0,0 +1 @@ +-deprecation
\ No newline at end of file diff --git a/test/files/neg/patmat-type-check.check b/test/files/neg/patmat-type-check.check new file mode 100644 index 0000000000..ab638b616d --- /dev/null +++ b/test/files/neg/patmat-type-check.check @@ -0,0 +1,21 @@ +patmat-type-check.scala:18: error: scrutinee is incompatible with pattern type; + found : Seq[A] + required: java.lang.String + def f1 = "bob".reverse match { case Seq('b', 'o', 'b') => true } // fail + ^ +patmat-type-check.scala:19: error: scrutinee is incompatible with pattern type; + found : Seq[A] + required: Array[Char] + def f2 = "bob".toArray match { case Seq('b', 'o', 'b') => true } // fail + ^ +patmat-type-check.scala:23: error: scrutinee is incompatible with pattern type; + found : Seq[A] + required: Test.Bop2 + def f3(x: Bop2) = x match { case Seq('b', 'o', 'b') => true } // fail + ^ +patmat-type-check.scala:27: error: scrutinee is incompatible with pattern type; + found : Seq[A] + required: Test.Bop3[T] + def f4[T](x: Bop3[T]) = x match { case Seq('b', 'o', 'b') => true } // fail + ^ +four errors found diff --git a/test/files/neg/patmat-type-check.scala b/test/files/neg/patmat-type-check.scala new file mode 100644 index 0000000000..c6c689b256 --- /dev/null +++ b/test/files/neg/patmat-type-check.scala @@ -0,0 +1,28 @@ +object Test +{ + def s1 = "bob".toList match { case Seq('b', 'o', 'b') => true } // list ok + + // not final, allowed + class Bop + def s2(x: Bop) = x match { case Seq('b', 'o', 'b') => true } + + // covariance, allowed + final class Bop4[+T] + def s3[T](x: Bop4[T]) = x match { case Seq('b', 'o', 'b') => true } + + // contravariance, allowed + final class Bop5[T, U, -V] + def s4[T1, T2](x: Bop5[_, T1, T2]) = x match { case Seq('b', 'o', 'b') => true } + + // String and Array are final/invariant, disallowed + def f1 = "bob".reverse match { case Seq('b', 'o', 'b') => true } // fail + def f2 = "bob".toArray match { case Seq('b', 'o', 'b') => true } // fail + + // final, no type parameters, should be disallowed + final class Bop2 + def f3(x: Bop2) = x match { case Seq('b', 'o', 'b') => true } // fail + + // final, invariant type parameter, should be disallowed + final class Bop3[T] + def f4[T](x: Bop3[T]) = x match { case Seq('b', 'o', 'b') => true } // fail +} diff --git a/test/files/neg/patmatexhaust.check b/test/files/neg/patmatexhaust.check index 1c46b6c9e5..ca769300c0 100644 --- a/test/files/neg/patmatexhaust.check +++ b/test/files/neg/patmatexhaust.check @@ -15,8 +15,8 @@ missing combination Qult Qult def ma3(x:Mult) = (x,x) match { // not exhaustive ^ patmatexhaust.scala:49: warning: match is not exhaustive! -missing combination Gu missing combination Gp +missing combination Gu def ma4(x:Deep) = x match { // missing cases: Gu, Gp ^ diff --git a/test/files/neg/t0528neg.scala b/test/files/neg/t0528neg.scala index 911745b763..30d20c95b1 100644 --- a/test/files/neg/t0528neg.scala +++ b/test/files/neg/t0528neg.scala @@ -3,7 +3,7 @@ trait Sequ[+A] { } class RichStr extends Sequ[Char] { - // override to a primitve array + // override to a primitive array def toArray: Array[Char] = new Array[Char](10) } diff --git a/test/files/neg/t0851.check b/test/files/neg/t0851.check deleted file mode 100644 index 61d2a98632..0000000000 --- a/test/files/neg/t0851.check +++ /dev/null @@ -1,9 +0,0 @@ -t0851.scala:14: error: not enough arguments for method apply: (v1: Int,v2: String)java.lang.String in trait Function2. -Unspecified value parameter v2. - println(f(1)) - ^ -t0851.scala:22: error: not enough arguments for method apply: (v1: Int,v2: String)java.lang.String in trait Function2. -Unspecified value parameter v2. - println(fn(1)) - ^ -two errors found diff --git a/test/files/neg/t0851.scala b/test/files/neg/t0851.scala deleted file mode 100644 index b28be2c697..0000000000 --- a/test/files/neg/t0851.scala +++ /dev/null @@ -1,25 +0,0 @@ -package test - -// This gives now type errors about missing parameters, which seems OK to me. -// The tests just make sure it does not crash - -object test1 { - case class Foo[T,T2](f : (T,T2) => String) extends (((T,T2)) => String){ - def apply(t : T) = (s:T2) => f(t,s) - def apply(p : (T,T2)) = f(p._1,p._2) - } - implicit def g[T](f : (T,String) => String) = Foo(f) - def main(args : Array[String]) : Unit = { - val f = (x:Int,s:String) => s + x - println(f(1)) - () - } -} -object Main { - def main(args : Array[String]) { - val fn = (a : Int, str : String) => "a: " + a + ", str: " + str - implicit def fx[T](f : (T,String) => String) = (x:T) => f(x,null) - println(fn(1)) - () - } -} diff --git a/test/files/neg/t2179.check b/test/files/neg/t2179.check index e454e117b5..aa94fabe1f 100644 --- a/test/files/neg/t2179.check +++ b/test/files/neg/t2179.check @@ -1,9 +1,9 @@ -t2179.scala:2: error: inferred type arguments [scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]{def sameElements[B >: Any](that: Iterable[B]): Boolean}]; def reverse: scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; protected def thisCollection: Seq[Double]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}; def dropRight(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def takeRight(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def slice(start: Int,end: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def take(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def drop(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}}] do not conform to method reduceLeft's type parameter bounds [B >: List[Double]] +t2179.scala:2: error: inferred type arguments [scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]; protected def thisCollection: Seq[Double]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}}] do not conform to method reduceLeft's type parameter bounds [B >: List[Double]] (Nil:List[List[Double]]).reduceLeft((_: Any, _: Any) => Nil.indices.map(_ => 0d)) ^ t2179.scala:2: error: type mismatch; found : (Any, Any) => scala.collection.immutable.IndexedSeq[Double] - required: (scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]{def sameElements[B >: Any](that: Iterable[B]): Boolean}]; def reverse: scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; protected def thisCollection: Seq[Double]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}; def dropRight(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def takeRight(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def slice(start: Int,end: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def take(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def drop(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}}, List[Double]) => scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]{def sameElements[B >: Any](that: Iterable[B]): Boolean}]; def reverse: scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; protected def thisCollection: Seq[Double]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}; def dropRight(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def takeRight(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def slice(start: Int,end: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def take(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def drop(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}} + required: (scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]; protected def thisCollection: Seq[Double]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}}, List[Double]) => scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]; protected def thisCollection: Seq[Double]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}} (Nil:List[List[Double]]).reduceLeft((_: Any, _: Any) => Nil.indices.map(_ => 0d)) ^ two errors found diff --git a/test/files/neg/t2386.check b/test/files/neg/t2386.check new file mode 100644 index 0000000000..2caa46c731 --- /dev/null +++ b/test/files/neg/t2386.check @@ -0,0 +1,4 @@ +t2386.scala:2: error: could not find implicit value for evidence parameter of type scala.reflect.ClassManifest[Array[_ >: java.lang.String with Int]] + val a = Array(Array(1, 2), Array("a","b")) + ^ +one error found diff --git a/test/files/neg/t2386.scala b/test/files/neg/t2386.scala new file mode 100644 index 0000000000..56146cc5c3 --- /dev/null +++ b/test/files/neg/t2386.scala @@ -0,0 +1,3 @@ +object Test { + val a = Array(Array(1, 2), Array("a","b")) +} diff --git a/test/files/neg/t2918.check b/test/files/neg/t2918.check new file mode 100644 index 0000000000..e67f24ec57 --- /dev/null +++ b/test/files/neg/t2918.check @@ -0,0 +1,7 @@ +t2918.scala:2: error: cyclic aliasing or subtyping involving type A + def g[X, A[X] <: A[X]](x: A[X]) = x + ^ +t2918.scala:2: error: A does not take type parameters + def g[X, A[X] <: A[X]](x: A[X]) = x + ^ +two errors found diff --git a/test/files/neg/t2918.scala b/test/files/neg/t2918.scala new file mode 100755 index 0000000000..ff2be39ae0 --- /dev/null +++ b/test/files/neg/t2918.scala @@ -0,0 +1,3 @@ +object Test { + def g[X, A[X] <: A[X]](x: A[X]) = x +} diff --git a/test/files/neg/t3006.check b/test/files/neg/t3006.check new file mode 100644 index 0000000000..9a90d32b28 --- /dev/null +++ b/test/files/neg/t3006.check @@ -0,0 +1,6 @@ +t3006.scala:8: error: type mismatch; + found : java.lang.String("H") + required: Int + println(A(3) + "H") + ^ +one error found diff --git a/test/files/neg/t3006.scala b/test/files/neg/t3006.scala new file mode 100755 index 0000000000..f476c1717d --- /dev/null +++ b/test/files/neg/t3006.scala @@ -0,0 +1,10 @@ +object Test extends Application { + case class A(x: Int); + + class Foo(a: A) { println("Foo created!"); def +(x: Int) = new A(this.a.x + x); } + + implicit def aToFoo(x: A) = new Foo(x); + + println(A(3) + "H") + +} diff --git a/test/files/neg/t3015.check b/test/files/neg/t3015.check new file mode 100644 index 0000000000..32809b0669 --- /dev/null +++ b/test/files/neg/t3015.check @@ -0,0 +1,11 @@ +t3015.scala:7: error: scrutinee is incompatible with pattern type; + found : _$1 where type _$1 + required: java.lang.String + val b(foo) = "foo" + ^ +t3015.scala:7: error: type mismatch; + found : _$1(in value foo) where type _$1(in value foo) <: java.lang.String + required: (some other)_$1(in value foo) where type (some other)_$1(in value foo) + val b(foo) = "foo" + ^ +two errors found diff --git a/test/files/neg/t3015.scala b/test/files/neg/t3015.scala new file mode 100644 index 0000000000..0bd53e7a03 --- /dev/null +++ b/test/files/neg/t3015.scala @@ -0,0 +1,8 @@ +class UnApp[P] { + def unapply(a: P): Option[P] = Some(a) +} + +object Test extends Application { + val b: UnApp[_] = new UnApp[String] + val b(foo) = "foo" +} diff --git a/test/files/neg/t3115.check b/test/files/neg/t3115.check new file mode 100644 index 0000000000..04f64eec3f --- /dev/null +++ b/test/files/neg/t3115.check @@ -0,0 +1,10 @@ +t3115.scala:6: error: object Math in object sc is deprecated: + println(sc.Math) + ^ +t3115.scala:7: error: object Math in package scala is deprecated: use scala.math package instead + println(scala.Math) + ^ +t3115.scala:8: error: object Math in package scala is deprecated: use scala.math package instead + scala.Math.Pi + ^ +three errors found diff --git a/test/files/neg/t3115.flags b/test/files/neg/t3115.flags new file mode 100644 index 0000000000..bf8f88334b --- /dev/null +++ b/test/files/neg/t3115.flags @@ -0,0 +1 @@ +-deprecation -Yfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t3115.scala b/test/files/neg/t3115.scala new file mode 100755 index 0000000000..4aeeb4063e --- /dev/null +++ b/test/files/neg/t3115.scala @@ -0,0 +1,9 @@ +object sc { + @deprecated("") object Math +} + +object Test { + println(sc.Math) + println(scala.Math) + scala.Math.Pi +} diff --git a/test/files/neg/t3118.check b/test/files/neg/t3118.check new file mode 100644 index 0000000000..da00f1c330 --- /dev/null +++ b/test/files/neg/t3118.check @@ -0,0 +1,7 @@ +t3118.scala:6: error: value C is not a member of O1 + println(x.C()) // should not be accessible + ^ +t3118.scala:7: error: type C is not a member of O1 + println(new x.C) // is correctly not accessible + ^ +two errors found diff --git a/test/files/neg/t3118.scala b/test/files/neg/t3118.scala new file mode 100644 index 0000000000..9be24c1ed4 --- /dev/null +++ b/test/files/neg/t3118.scala @@ -0,0 +1,8 @@ +class O1 { + private[this] case class C() + + val x = new O1 + + println(x.C()) // should not be accessible + println(new x.C) // is correctly not accessible +} diff --git a/test/files/neg/t3222.check b/test/files/neg/t3222.check new file mode 100644 index 0000000000..6170827cc9 --- /dev/null +++ b/test/files/neg/t3222.check @@ -0,0 +1,13 @@ +t3222.scala:1: error: not found: type B +@throws(classOf[B]) + ^ +t3222.scala:4: error: not found: type D + def foo(@throws(classOf[D]) x: Int) {} + ^ +t3222.scala:3: error: not found: type C + @throws(classOf[C]) + ^ +t3222.scala:6: error: not found: type E + @throws(classOf[E]) + ^ +four errors found diff --git a/test/files/neg/t3222.scala b/test/files/neg/t3222.scala new file mode 100644 index 0000000000..448292e8a7 --- /dev/null +++ b/test/files/neg/t3222.scala @@ -0,0 +1,9 @@ +@throws(classOf[B]) +class ExceptionTest { + @throws(classOf[C]) + def foo(@throws(classOf[D]) x: Int) {} + + @throws(classOf[E]) + type t = String +} + diff --git a/test/files/neg/unit2anyref.check b/test/files/neg/unit2anyref.check index 7af4564ffb..2616fd35f9 100644 --- a/test/files/neg/unit2anyref.check +++ b/test/files/neg/unit2anyref.check @@ -1,10 +1,8 @@ unit2anyref.scala:2: error: type mismatch; found : Unit required: AnyRef -Note that implicit conversions are not applicable because they are ambiguous: - both method any2stringadd in object Predef of type (x: Any)scala.runtime.StringAdd - and method any2ArrowAssoc in object Predef of type [A](x: A)ArrowAssoc[A] - are possible conversion functions from Unit to AnyRef +Note: primitive types are not implicitly converted to AnyRef. +You can safely force boxing by casting x.asInstanceOf[AnyRef]. val x: AnyRef = () // this should not succeed. ^ one error found |