diff options
Diffstat (limited to 'test/files/neg')
28 files changed, 196 insertions, 70 deletions
diff --git a/test/files/neg/abstract-class-2.check b/test/files/neg/abstract-class-2.check new file mode 100644 index 0000000000..ca79dd8293 --- /dev/null +++ b/test/files/neg/abstract-class-2.check @@ -0,0 +1,5 @@ +abstract-class-2.scala:11: error: object creation impossible, since method f in trait S2 of type (x: P2.this.p.S1)Int is not defined +(Note that P.this.p.S1 does not match P2.this.S1: their prefixes (i.e. enclosing instances) differ) + object O2 extends S2 { + ^ +one error found diff --git a/test/files/neg/abstract-class-2.scala b/test/files/neg/abstract-class-2.scala new file mode 100644 index 0000000000..19f74f3da6 --- /dev/null +++ b/test/files/neg/abstract-class-2.scala @@ -0,0 +1,14 @@ +class P { + trait S1 + val p = new P + + trait S2 { + def f(x: p.S1): Int + } +} + +class P2 extends P { + object O2 extends S2 { + def f(x: S1) = 5 + } +} diff --git a/test/files/neg/abstract-class-error.check b/test/files/neg/abstract-class-error.check new file mode 100644 index 0000000000..87d148ecc5 --- /dev/null +++ b/test/files/neg/abstract-class-error.check @@ -0,0 +1,5 @@ +S.scala:1: error: class S needs to be abstract, since method g in class J of type (y: Int, z: java.util.List)Int is not defined +(Note that java.util.List does not match java.util.List[String]. To implement a raw type, use java.util.List[_]) +class S extends J { + ^ +one error found diff --git a/test/files/neg/abstract-class-error/J.java b/test/files/neg/abstract-class-error/J.java new file mode 100644 index 0000000000..5877f5cc5b --- /dev/null +++ b/test/files/neg/abstract-class-error/J.java @@ -0,0 +1,4 @@ +public abstract class J { + public abstract int f(); + public abstract int g(int y, java.util.List z); +}
\ No newline at end of file diff --git a/test/files/neg/abstract-class-error/S.scala b/test/files/neg/abstract-class-error/S.scala new file mode 100644 index 0000000000..67f6d8593e --- /dev/null +++ b/test/files/neg/abstract-class-error/S.scala @@ -0,0 +1,4 @@ +class S extends J { + def f() = 55 + def g(y: Int, z: java.util.List[String]) = 11 +} diff --git a/test/files/neg/accesses.check b/test/files/neg/accesses.check index 94fcd615bc..db58af12ce 100644 --- a/test/files/neg/accesses.check +++ b/test/files/neg/accesses.check @@ -1,17 +1,17 @@ -accesses.scala:23: error: overriding method f2 in class A of type => Unit; +accesses.scala:23: error: overriding method f2 in class A of type ()Unit; method f2 has weaker access privileges; it should not be private - private def f2: Unit = () + private def f2(): Unit = () ^ -accesses.scala:24: error: overriding method f3 in class A of type => Unit; +accesses.scala:24: error: overriding method f3 in class A of type ()Unit; method f3 has weaker access privileges; it should be at least protected - private[p2] def f3: Unit = () + private[p2] def f3(): Unit = () ^ -accesses.scala:25: error: overriding method f4 in class A of type => Unit; +accesses.scala:25: error: overriding method f4 in class A of type ()Unit; method f4 has weaker access privileges; it should be at least private[p1] - private[p2] def f4: Unit + private[p2] def f4(): Unit ^ -accesses.scala:26: error: overriding method f5 in class A of type => Unit; +accesses.scala:26: error: overriding method f5 in class A of type ()Unit; method f5 has weaker access privileges; it should be at least protected[p1] - protected[p2] def f5: Unit + protected[p2] def f5(): Unit ^ four errors found diff --git a/test/files/neg/accesses.scala b/test/files/neg/accesses.scala index 2a6b45c35b..b1df6c0e6c 100644 --- a/test/files/neg/accesses.scala +++ b/test/files/neg/accesses.scala @@ -1,27 +1,27 @@ package test.p1.p2 abstract class A { - private[p2] def f2: Unit - protected def f3: Unit - private[p1] def f4: Unit - protected[p1] def f5: Unit + private[p2] def f2(): Unit + protected def f3(): Unit + private[p1] def f4(): Unit + protected[p1] def f5(): Unit } abstract class OK1 extends A { - private[p1] def f2: Unit - protected[p2] def f3: Unit - private[test] def f4: Unit - protected[test] def f5: Unit + private[p1] def f2(): Unit + protected[p2] def f3(): Unit + private[test] def f4(): Unit + protected[test] def f5(): Unit } abstract class OK2 extends A { - protected[p1] def f2: Unit - def f3: Unit - protected[p1] def f4: Unit - def f5: Unit + protected[p1] def f2(): Unit + def f3(): Unit + protected[p1] def f4(): Unit + def f5(): Unit } abstract class Err1 extends A { - private def f2: Unit = () - private[p2] def f3: Unit = () - private[p2] def f4: Unit - protected[p2] def f5: Unit + private def f2(): Unit = () + private[p2] def f3(): Unit = () + private[p2] def f4(): Unit + protected[p2] def f5(): Unit } diff --git a/test/files/neg/bug1960.check b/test/files/neg/bug1960.check index 6615d90036..8e19f31ef5 100644 --- a/test/files/neg/bug1960.check +++ b/test/files/neg/bug1960.check @@ -1,4 +1,4 @@ bug1960.scala:5: error: parameter 'p' requires field but conflicts with p in 'TBase' -class Aclass (p: Int) extends TBase { def g{ f(p) } } +class Aclass (p: Int) extends TBase { def g() { f(p) } } ^ one error found diff --git a/test/files/neg/bug1960.scala b/test/files/neg/bug1960.scala index af7f270356..5311940b5a 100644 --- a/test/files/neg/bug1960.scala +++ b/test/files/neg/bug1960.scala @@ -2,4 +2,4 @@ object ClassFormatErrorExample extends App { new Aclass(1) } trait TBase { var p:Int = 0; def f(p1: Int) {} } -class Aclass (p: Int) extends TBase { def g{ f(p) } } +class Aclass (p: Int) extends TBase { def g() { f(p) } } diff --git a/test/files/neg/bug4533.check b/test/files/neg/bug4533.check new file mode 100644 index 0000000000..e1b60aa820 --- /dev/null +++ b/test/files/neg/bug4533.check @@ -0,0 +1,4 @@ +bug4533.scala:6: error: erroneous or inaccessible type + def statusByAlarms(alarms: GenTraversableOnce[FooAlarm]) = println("hello") + ^ +one error found diff --git a/test/files/neg/bug4533.scala b/test/files/neg/bug4533.scala new file mode 100644 index 0000000000..0346b5d1d5 --- /dev/null +++ b/test/files/neg/bug4533.scala @@ -0,0 +1,8 @@ +package demo + +import scala.collection._ + +class CrashDemo { + def statusByAlarms(alarms: GenTraversableOnce[FooAlarm]) = println("hello") +} +class FooAlarm { } diff --git a/test/files/neg/bug630.scala b/test/files/neg/bug630.scala index d236b51ffd..8a073963b0 100644 --- a/test/files/neg/bug630.scala +++ b/test/files/neg/bug630.scala @@ -1,7 +1,7 @@ trait Req1 trait Req2 { - def test = Console.println("Test") + def test() = Console.println("Test") } trait Foo { @@ -10,7 +10,7 @@ trait Foo { trait Bar { val foo : Req2 - def test = foo.test + def test() = foo.test } object Test diff --git a/test/files/neg/exhausting.check b/test/files/neg/exhausting.check index d3f2251f79..0bef21e077 100644 --- a/test/files/neg/exhausting.check +++ b/test/files/neg/exhausting.check @@ -2,7 +2,7 @@ exhausting.scala:20: error: match is not exhaustive! missing combination * Nil def fail1[T](xs: List[T]) = xs match { - ^ + ^ exhausting.scala:24: error: match is not exhaustive! missing combination Nil @@ -17,7 +17,7 @@ exhausting.scala:31: error: match is not exhaustive! missing combination Bar2 Bar2 def fail4[T <: AnyRef](xx: (Foo[T], Foo[T])) = xx match { - ^ + ^ exhausting.scala:36: error: match is not exhaustive! missing combination Bar1 Bar2 missing combination Bar1 Bar3 @@ -25,5 +25,5 @@ missing combination Bar2 Bar1 missing combination Bar2 Bar2 def fail5[T](xx: (Foo[T], Foo[T])) = xx match { - ^ + ^ 5 errors found diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check index 5d409f18a8..d2bd2d123b 100644 --- a/test/files/neg/names-defaults-neg.check +++ b/test/files/neg/names-defaults-neg.check @@ -1,4 +1,4 @@ -names-defaults-neg.scala:65: error: not enough arguments for method apply: (a: Int,b: String)(c: Int*)Fact in object Fact. +names-defaults-neg.scala:65: error: not enough arguments for method apply: (a: Int, b: String)(c: Int*)Fact in object Fact. Unspecified value parameter b. val fac = Fact(1)(2, 3) ^ @@ -40,8 +40,8 @@ names-defaults-neg.scala:26: error: Int does not take parameters test3(b = 3, a = 1)(3) ^ names-defaults-neg.scala:35: error: ambiguous reference to overloaded definition, -both method f in object t1 of type (b: String,a: Int)java.lang.String -and method f in object t1 of type (a: Int,b: String)java.lang.String +both method f in object t1 of type (b: String, a: Int)java.lang.String +and method f in object t1 of type (a: Int, b: String)java.lang.String match argument types (b: java.lang.String,a: Int) t1.f(b = "dkljf", a = 1) ^ @@ -59,7 +59,7 @@ match argument types (Int) ^ names-defaults-neg.scala:49: error: ambiguous reference to overloaded definition, both method g in object t7 of type (a: B)java.lang.String -and method g in object t7 of type (a: C,b: Int*)java.lang.String +and method g in object t7 of type (a: C, b: Int*)java.lang.String match argument types (C) t7.g(new C()) // ambigous reference ^ @@ -73,19 +73,19 @@ names-defaults-neg.scala:55: error: when using named arguments, the vararg param test5(b = "dlkj") ^ names-defaults-neg.scala:61: error: ambiguous reference to overloaded definition, -both method f in object t8 of type (b: String,a: Int)java.lang.String -and method f in object t8 of type (a: Int,b: java.lang.Object)java.lang.String +both method f in object t8 of type (b: String, a: Int)java.lang.String +and method f in object t8 of type (a: Int, b: java.lang.Object)java.lang.String match argument types (a: Int,b: java.lang.String) and expected result type Any println(t8.f(a = 0, b = "1")) // ambigous reference ^ -names-defaults-neg.scala:69: error: wrong number of arguments for <none>: (x: Int,y: String)A1 +names-defaults-neg.scala:69: error: wrong number of arguments for <none>: (x: Int, y: String)A1 A1() match { case A1(_) => () } ^ names-defaults-neg.scala:76: error: no type parameters for method test4: (x: T[T[List[T[X forSome { type X }]]]])T[T[List[T[X forSome { type X }]]]] exist so that it can be applied to arguments (List[Int]) --- because --- argument expression's type is not compatible with formal parameter type; found : List[Int] - required: ?T[ ?T[ List[?T[ X forSome { type X } ]] ] ] + required: ?T[?T[List[?T[X forSome { type X }]]]] Error occurred in an application involving default arguments. test4() ^ diff --git a/test/files/neg/patmatexhaust.check b/test/files/neg/patmatexhaust.check index 83c4279b0a..8aa9238d2e 100644 --- a/test/files/neg/patmatexhaust.check +++ b/test/files/neg/patmatexhaust.check @@ -1,37 +1,38 @@ -patmatexhaust.scala:7: warning: match is not exhaustive! +patmatexhaust.scala:7: error: match is not exhaustive! missing combination Baz def ma1(x:Foo) = x match { ^ -patmatexhaust.scala:11: warning: match is not exhaustive! +patmatexhaust.scala:11: error: match is not exhaustive! missing combination Bar def ma2(x:Foo) = x match { ^ -patmatexhaust.scala:23: warning: match is not exhaustive! +patmatexhaust.scala:23: error: match is not exhaustive! missing combination Kult Kult missing combination Qult Qult def ma3(x:Mult) = (x,x) match { // not exhaustive - ^ -patmatexhaust.scala:49: warning: match is not exhaustive! + ^ +patmatexhaust.scala:49: error: match is not exhaustive! missing combination Gp missing combination Gu def ma4(x:Deep) = x match { // missing cases: Gu, Gp ^ -patmatexhaust.scala:53: warning: match is not exhaustive! +patmatexhaust.scala:53: error: match is not exhaustive! missing combination Gp def ma5(x:Deep) = x match { // Gp ^ -patmatexhaust.scala:75: warning: match is not exhaustive! +patmatexhaust.scala:59: error: match is not exhaustive! +missing combination Nil + + def ma6() = List(1,2) match { // give up + ^ +patmatexhaust.scala:75: error: match is not exhaustive! missing combination B def ma9(x: B) = x match { ^ -patmatexhaust.scala:92: error: unreachable code - case 1 => - ^ -6 warnings found -one error found +7 errors found diff --git a/test/files/neg/patmatexhaust.flags b/test/files/neg/patmatexhaust.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/patmatexhaust.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/patmatexhaust.scala b/test/files/neg/patmatexhaust.scala index b172df8740..d49c4b207b 100644 --- a/test/files/neg/patmatexhaust.scala +++ b/test/files/neg/patmatexhaust.scala @@ -56,12 +56,12 @@ class TestSealedExhaustive { // compile only case Ga => } - def ma6 = List(1,2) match { // give up + def ma6() = List(1,2) match { // give up case List(1,2) => case x :: xs => } - def ma7 = List(1,2) match { //exhaustive + def ma7() = List(1,2) match { //exhaustive case 1::2::Nil => case _ => } @@ -86,10 +86,4 @@ class TestSealedExhaustive { // compile only case C4() => true case C2 | C6 => true } - - def redundant = 1 match { // include this otherwise script won't test this in files/neg - case 1 => - case 1 => - } - } diff --git a/test/files/neg/t2910.check b/test/files/neg/t2910.check index afff73ec08..ff190122d6 100644 --- a/test/files/neg/t2910.check +++ b/test/files/neg/t2910.check @@ -13,4 +13,4 @@ t2910.scala:30: error: forward reference extends over definition of value x t2910.scala:34: error: forward reference extends over definition of variable x lazy val f: Int = g ^ -5 errors found
\ No newline at end of file +5 errors found diff --git a/test/files/neg/t2910.scala b/test/files/neg/t2910.scala index 1c7ba54971..b772ee4d43 100644 --- a/test/files/neg/t2910.scala +++ b/test/files/neg/t2910.scala @@ -5,13 +5,13 @@ object Junk { ret } - def test2 { + def test2() { println(s.length) val z = 0 lazy val s = "abc" } - def test4 { + def test4() { lazy val x = { x val z = 0 diff --git a/test/files/neg/t3115.check b/test/files/neg/t3115.check index 3da8c8d1c6..c128ff5f3f 100644 --- a/test/files/neg/t3115.check +++ b/test/files/neg/t3115.check @@ -1,11 +1,11 @@ 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 the scala.math package object instead. +t3115.scala:7: error: object Math is deprecated: use the scala.math package object instead. (Example package object usage: scala.math.Pi ) println(scala.Math) ^ -t3115.scala:8: error: object Math in package scala is deprecated: use the scala.math package object instead. +t3115.scala:8: error: object Math is deprecated: use the scala.math package object instead. (Example package object usage: scala.math.Pi ) scala.Math.Pi ^ diff --git a/test/files/neg/t3774.check b/test/files/neg/t3774.check index ea35c50541..cce2d7076c 100644 --- a/test/files/neg/t3774.check +++ b/test/files/neg/t3774.check @@ -1,6 +1,6 @@ t3774.scala:4: error: overloaded method value ++ with alternatives: [B1 >: List[Int]](xs: scala.collection.GenTraversableOnce[((Int, Int), B1)])scala.collection.immutable.Map[(Int, Int),B1] <and> - [B >: ((Int, Int), List[Int]),That](that: scala.collection.GenTraversableOnce[B])(implicit bf: scala.collection.generic.CanBuildFrom[scala.collection.immutable.Map[(Int, Int),List[Int]],B,That])That + [B >: ((Int, Int), List[Int]), That](that: scala.collection.GenTraversableOnce[B])(implicit bf: scala.collection.generic.CanBuildFrom[scala.collection.immutable.Map[(Int, Int),List[Int]],B,That])That cannot be applied to (scala.collection.immutable.IndexedSeq[((Int, Int), scala.collection.immutable.Range.Inclusive)]) Map[(Int,Int),List[Int]]() ++ (for(x <- 0 to 1 ; y <- 0 to 1) yield {(x,y)-> (0 to 1)}) ^ diff --git a/test/files/neg/t4457_1.check b/test/files/neg/t4457_1.check new file mode 100644 index 0000000000..c6b83c6ce5 --- /dev/null +++ b/test/files/neg/t4457_1.check @@ -0,0 +1,7 @@ +t4457_1.scala:27: error: ambiguous reference to overloaded definition, +both method aFunc in object ImplicitConvAmbiguity2 of type [A](a: ImplicitConvAmbiguity2.NZ[A])ImplicitConvAmbiguity2.AA[Float] +and method aFunc in object ImplicitConvAmbiguity2 of type [A](a: ImplicitConvAmbiguity2.NE[A])ImplicitConvAmbiguity2.AA[A] +match argument types (Float) + val x = aFunc(4F) + ^ +one error found diff --git a/test/files/neg/t4457_1.scala b/test/files/neg/t4457_1.scala new file mode 100644 index 0000000000..11f12379f6 --- /dev/null +++ b/test/files/neg/t4457_1.scala @@ -0,0 +1,33 @@ +object ImplicitConvAmbiguity2 { + + class N[T] + class NE[T] extends N[T] + class NN[T] extends N[T] + class NQ[T] extends N[T] + class NZ[T] extends N[T] + class AA[A] + class BB[A] + + implicit def conv1(i: Float) = new NE[Float] + implicit def conv3(op: AA[java.util.TooManyListenersException]) = new N[java.util.TooManyListenersException] + implicit def conv4(op: AA[Float]) = new N[Float] + implicit def conv7(i: Float) = new NZ[Float] + implicit def conv5(e: BB[java.util.GregorianCalendar]) = new N[java.util.GregorianCalendar] + + // These two will be in conflict in typeMe1 + def aFunc[A](a: NE[A]) = new AA[A] + def aFunc[A](a: NZ[A]) = new AA[Float] + + def aFunc[A](a: NN[A]) = new BB[A] + def aFunc[A](a: NQ[A]) = new BB[A] + + def bFunc[T](e1: N[T]) = {} + + def typeMe1 { + val x = aFunc(4F) + bFunc(x) + } + def typeMe2 { + bFunc(aFunc(4F)) + } +} diff --git a/test/files/neg/t4457_2.check b/test/files/neg/t4457_2.check new file mode 100644 index 0000000000..770a355395 --- /dev/null +++ b/test/files/neg/t4457_2.check @@ -0,0 +1,13 @@ +t4457_2.scala:27: error: ambiguous reference to overloaded definition, +both method aFunc in object ImplicitConvAmbiguity2 of type [A](a: ImplicitConvAmbiguity2.NZ[A])ImplicitConvAmbiguity2.AA[A] +and method aFunc in object ImplicitConvAmbiguity2 of type [A](a: ImplicitConvAmbiguity2.NE[A])ImplicitConvAmbiguity2.AA[A] +match argument types (Float) + val x = aFunc(4F) + ^ +t4457_2.scala:31: error: ambiguous reference to overloaded definition, +both method aFunc in object ImplicitConvAmbiguity2 of type [A](a: ImplicitConvAmbiguity2.NZ[A])ImplicitConvAmbiguity2.AA[A] +and method aFunc in object ImplicitConvAmbiguity2 of type [A](a: ImplicitConvAmbiguity2.NE[A])ImplicitConvAmbiguity2.AA[A] +match argument types (Float) + bFunc(aFunc(4F)) + ^ +two errors found diff --git a/test/files/neg/t4457_2.scala b/test/files/neg/t4457_2.scala new file mode 100644 index 0000000000..f3a170f1f2 --- /dev/null +++ b/test/files/neg/t4457_2.scala @@ -0,0 +1,33 @@ +object ImplicitConvAmbiguity2 { + + class N[T] + class NE[T] extends N[T] + class NN[T] extends N[T] + class NQ[T] extends N[T] + class NZ[T] extends N[T] + class AA[A] + class BB[A] + + implicit def conv1(i: Float) = new NE[Float] + implicit def conv3(op: AA[java.util.TooManyListenersException]) = new N[java.util.TooManyListenersException] + implicit def conv4(op: AA[Float]) = new N[Float] + implicit def conv7(i: Float) = new NZ[Float] + implicit def conv5(e: BB[java.util.GregorianCalendar]) = new N[java.util.GregorianCalendar] + + def aFunc[A](a: NE[A]) = new AA[A] + def aFunc[A](a: NZ[A]) = new AA[A] + + def aFunc[A](a: NN[A]) = new BB[A] + + def aFunc[A](a: NQ[A]) = new BB[A] + + def bFunc[T](e1: N[T]) = {} + + def typeMe2 { + val x = aFunc(4F) + bFunc(x) + } + def typeMe1 { + bFunc(aFunc(4F)) + } +} diff --git a/test/files/neg/tailrec.scala b/test/files/neg/tailrec.scala index a77f439cfe..e0ebde9863 100644 --- a/test/files/neg/tailrec.scala +++ b/test/files/neg/tailrec.scala @@ -10,7 +10,7 @@ object Winners { @tailrec def loopsucc1(x: Int): Int = loopsucc1(x - 1) @tailrec def loopsucc2[T](x: Int): Int = loopsucc2[T](x - 1) - def ding { + def ding() { object dong { @tailrec def loopsucc3(x: Int): Int = loopsucc3(x) } diff --git a/test/files/neg/tcpoly_infer_ticket1162.check b/test/files/neg/tcpoly_infer_ticket1162.check index 03334222c1..67b79e7f3c 100644 --- a/test/files/neg/tcpoly_infer_ticket1162.check +++ b/test/files/neg/tcpoly_infer_ticket1162.check @@ -1,4 +1,4 @@ -tcpoly_infer_ticket1162.scala:6: error: wrong number of type parameters for method apply: [A,B,F[_]]()Test.Lift[A,B,F] in object Lift +tcpoly_infer_ticket1162.scala:6: error: wrong number of type parameters for method apply: [A, B, F[_]]()Test.Lift[A,B,F] in object Lift def simplify[A,B]: Expression[A,B] = Lift[A,B]() ^ one error found diff --git a/test/files/neg/varargs.check b/test/files/neg/varargs.check index 1352dd968c..676a611341 100644 --- a/test/files/neg/varargs.check +++ b/test/files/neg/varargs.check @@ -1,10 +1,10 @@ -varargs.scala:16: error: A method with a varargs annotation produces a forwarder method with the same signature (a: Int,b: Array[java.lang.String])Int as an existing method. +varargs.scala:16: error: A method with a varargs annotation produces a forwarder method with the same signature (a: Int, b: Array[java.lang.String])Int as an existing method. @varargs def v1(a: Int, b: String*) = a + b.length ^ varargs.scala:19: error: A method without repeated parameters cannot be annotated with the `varargs` annotation. @varargs def nov(a: Int) = 0 ^ -varargs.scala:21: error: A method with a varargs annotation produces a forwarder method with the same signature (a: Int,b: Array[java.lang.String])Int as an existing method. +varargs.scala:21: error: A method with a varargs annotation produces a forwarder method with the same signature (a: Int, b: Array[java.lang.String])Int as an existing method. @varargs def v2(a: Int, b: String*) = 0 ^ -three errors found
\ No newline at end of file +three errors found |