Skip to content

Commit f36e22b

Browse files
committed
More neg tests
Some random neg tests from previous experiments.
1 parent 795e09e commit f36e22b

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

tests/neg/classOf.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object Test {
2+
3+
class C { type I }
4+
type A = C
5+
6+
def f1[T] = classOf[T] // error
7+
def f2[T <: String] = classOf[T] // error
8+
val x = classOf[Test.type] // error
9+
val y = classOf[C { type I = String }] // error
10+
val z = classOf[A] // ok
11+
}

tests/neg/tate.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object unsound {
2+
trait Bound[A, B <: A]
3+
trait Bind[A] {
4+
def bad[B <: A](bound: Bound[A, B], b: B) = b
5+
}
6+
def coerce[T, U](t: T): U = {
7+
lazy val bound: Bound[U, _ >: T] = ??? // error: >: T does not conform to upper bound
8+
def bind = new Bind[U] {}
9+
bind.bad(bound, t)
10+
}
11+
}

tests/pending/neg/tate.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
trait Out[+T]
2+
3+
object Test {
4+
5+
def foo[T <% AnyRef](x: T) = ???
6+
7+
var x: Out[_ >: String] = ???
8+
var y: Out[String] = ???
9+
x = y // should give error, but currently masked by covariant alias representation
10+
// y = x
11+
}

0 commit comments

Comments
 (0)