From 8881a98223832f28993263fcd147e2a7a1a51110 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 7 Mar 2016 15:11:19 +0100 Subject: More neg tests Some random neg tests from previous experiments. --- tests/neg/classOf.scala | 11 +++++++++++ tests/neg/tate.scala | 11 +++++++++++ tests/pending/neg/tate.scala | 11 +++++++++++ 3 files changed, 33 insertions(+) create mode 100644 tests/neg/classOf.scala create mode 100644 tests/neg/tate.scala create mode 100644 tests/pending/neg/tate.scala (limited to 'tests') diff --git a/tests/neg/classOf.scala b/tests/neg/classOf.scala new file mode 100644 index 000000000..e13cf71c4 --- /dev/null +++ b/tests/neg/classOf.scala @@ -0,0 +1,11 @@ +object Test { + + class C { type I } + type A = C + + def f1[T] = classOf[T] // error + def f2[T <: String] = classOf[T] // error + val x = classOf[Test.type] // error + val y = classOf[C { type I = String }] // error + val z = classOf[A] // ok +} diff --git a/tests/neg/tate.scala b/tests/neg/tate.scala new file mode 100644 index 000000000..acf7ee7e3 --- /dev/null +++ b/tests/neg/tate.scala @@ -0,0 +1,11 @@ + object unsound { + trait Bound[A, B <: A] + trait Bind[A] { + def bad[B <: A](bound: Bound[A, B], b: B) = b + } + def coerce[T, U](t: T): U = { + lazy val bound: Bound[U, _ >: T] = ??? // error: >: T does not conform to upper bound + def bind = new Bind[U] {} + bind.bad(bound, t) + } + } diff --git a/tests/pending/neg/tate.scala b/tests/pending/neg/tate.scala new file mode 100644 index 000000000..d626ccd3f --- /dev/null +++ b/tests/pending/neg/tate.scala @@ -0,0 +1,11 @@ +trait Out[+T] + +object Test { + + def foo[T <% AnyRef](x: T) = ??? + + var x: Out[_ >: String] = ??? + var y: Out[String] = ??? + x = y // should give error, but currently masked by covariant alias representation + // y = x +} -- cgit v1.2.3