From 447256c89148e07dfddcfc065bd5f0946b0ae9aa Mon Sep 17 00:00:00 2001 From: VladimirNik Date: Mon, 22 Feb 2016 14:50:35 +0100 Subject: Neg tests: remove xerror parameter from tests (compute based on // error) --- tests/neg/customArgs/i1050.scala | 183 +++++++++++++++++++++++++++++++ tests/neg/customArgs/overrideClass.scala | 20 ++++ tests/neg/customArgs/typers.scala | 69 ++++++++++++ 3 files changed, 272 insertions(+) create mode 100644 tests/neg/customArgs/i1050.scala create mode 100644 tests/neg/customArgs/overrideClass.scala create mode 100644 tests/neg/customArgs/typers.scala (limited to 'tests/neg/customArgs') diff --git a/tests/neg/customArgs/i1050.scala b/tests/neg/customArgs/i1050.scala new file mode 100644 index 000000000..1ade1366a --- /dev/null +++ b/tests/neg/customArgs/i1050.scala @@ -0,0 +1,183 @@ +// i1050 checks failing at posttyper +trait A { type L <: Nothing } +trait B { type L >: Any} +object Test { + lazy val x: A & B = ??? + val y: x.L = 1 // error: underlying conflicting bounds + val z: String = y +} +object Test50 { + trait A { + type X = String + } + trait B { + type X = Int + } + lazy val o: A & B = ??? + + def xToString(x: o.X): String = x // error: underlying conflicting bounds + + def intToString(i: Int): String = xToString(i) + + def main(args: Array[String]) = { + val s: String = intToString(1) + } +} +object Test2 { + + trait C { type A } + + type T = C { type A = Any } + type U = C { type A = Nothing } + type X = T & U + + def main(args: Array[String]) = { + val y: X#A = 1 // error: conflicting bounds + val z: String = y + } +} +object Tiark1 { + trait A { type L <: Nothing } + trait B { type L >: Any} + trait U { + lazy val p: B + def brand(x: Any): p.L = x // error: nonfinal lazy + } + trait V extends U { + lazy val p: A & B = ??? + } + val v = new V {} + v.brand("boom!") +} +object Tiark2 { + trait A { type L <: Nothing } + trait B { type L >: Any} + trait U { + type X <: B + lazy val p: X + def brand(x: Any): p.L = x // error: nonfinal lazy + } + trait V extends U { + type X = B & A + lazy val p: X = ??? + } + val v = new V {} + v.brand("boom!"): Nothing +} +object Tiark3 { + trait A { type L <: Nothing } + trait B { type L >: Any} + trait U { + type X <: B + def p2: X + final lazy val p: X = p2 + def brand(x: Any): p.L = x // error: underlying not concrete + } + trait V extends U { + type X = B with A + def p2: X = ??? + } + val v = new V {} + v.brand("boom!"): Nothing +} +object Tiark6 { + trait B { type L >: Any } + trait A { type L <: Nothing } + trait U { + trait X { + val q: A & B = ??? + } + final lazy val p: X = ??? + def brand(x: Any): p.q.L = x // error: conflicting bounds + } + val v = new U {} + v.brand("boom!"): Nothing +} + +object Indirect { + trait B { type L >: Any } + trait A { type L <: Nothing } + trait U { + trait X { + val q: A & B = ??? + type M = q.L + } + final lazy val p: X = ??? + def brand(x: Any): p.M = x // error: conflicting bounds + } + def main(args: Array[String]): Unit = { + val v = new U {} + v.brand("boom!"): Nothing + } +} +object Indirect2 { + trait B { type L >: Any } + trait A { type L <: Nothing } + trait U { + trait Y { + val r: A & B = ??? + } + trait X { + val q: Y = ??? + type M = q.r.L + } + final lazy val p: X = ??? + def brand(x: Any): p.M = x // error: conflicting bounds + } + def main(args: Array[String]): Unit = { + val v = new U {} + v.brand("boom!"): Nothing + } +} +object Rec1 { + trait B { type L >: Any } + trait A { type L <: Nothing } + trait U { + trait Y { + type L = Int + val r: Y + } + trait X { + val q: Y = ??? + type M = q.r.L // if we are not careful we get a stackoverflow here + } + } +} +object Rec2 { + trait B { type L >: Any } + trait A { type L <: Nothing } + trait U { + trait Y { + val r: A & B & Y + } + trait X { + val q: Y = ??? + type M = q.r.L + } + final lazy val p: X = ??? + def brand(x: Any): p.M = x // error: conflicting bounds + } + def main(args: Array[String]): Unit = { + val v = new U {} + v.brand("boom!"): Nothing + } +} +object Indirect3 { + trait B { type L >: Any } + trait A { type L <: Nothing } + trait U { + trait Y { + val r: Y & A & B = ??? + } + trait X { + val q: Y = ??? + type M = q.r.L + } + final lazy val p: X = ??? + def brand(x: Any): p.M = x // error: conflicting bounds + } + def main(args: Array[String]): Unit = { + val v = new U {} + v.brand("boom!"): Nothing + } +} diff --git a/tests/neg/customArgs/overrideClass.scala b/tests/neg/customArgs/overrideClass.scala new file mode 100644 index 000000000..803d97dd9 --- /dev/null +++ b/tests/neg/customArgs/overrideClass.scala @@ -0,0 +1,20 @@ + abstract class FooA { + type A <: Ax; + abstract class Ax; + abstract class InnerA { + type B <: A; + def doB : B; + } + } + trait FooB extends FooA { + type A <: Ax; + trait Ax extends super.Ax { def xxx : Int; } // error: cyclic inheritance: trait Ax extends itself + // (Note that inheriting a class of the same name is no longer allowed) + abstract class InnerB extends InnerA { + // type B <: A; + val a : A = doB; + a.xxx; + doB.xxx; + } + } + diff --git a/tests/neg/customArgs/typers.scala b/tests/neg/customArgs/typers.scala new file mode 100644 index 000000000..49742ebbd --- /dev/null +++ b/tests/neg/customArgs/typers.scala @@ -0,0 +1,69 @@ +object typers { + + class A(x: Int) { + val x: String = "a" // error: double def + + { val y: String = "" + val y: Int = 0 // error: double def + y + } + } + + class B { self => // error: double def + def self: Int = 0 + def self(x: Int): Int = x + } + + class C { + val x: Int + val x: String // error: double def + val y: Int + def y: String // error: double def + val z: Int + def z(): String // error: double def + + def f(x: Any) = () // OK! + def f(x: AnyRef): AnyRef + + def g(x: Object): Unit + def g[T](x: T): T = x // OK! + } + + type L[X] = scala.collection.immutable.List[X] + type M[X, Y] <: scala.collection.immutable.Map[X, Y] // error: only classes can have declared but undefined members + + object hk { + def f(x: L) // error: missing type parameter + : M = // error: missing type parameter + ??? : M // error: missing type parameter + } + + object returns { + + def foo(x: Int) = { + return 3 // error: has return; needs result type + } + + return 4 // error: return outside method definition + } + + object cyclic { + def factorial(acc: Int, n: Int) = + if (n == 0) acc + else factorial(acc * n, n - 1) // error: cyclic reference + + def foo(x: Int) = x + def foo() = foo(1) // error: cyclic reference + + } + + object tries { + + val x = try { + "abc" + } catch { + case ex: String => // does not work yet. We should detect that the test is non-sensical, but don't. + 123 + } + } +} -- cgit v1.2.3