diff options
Diffstat (limited to 'test/pending/pos/nothing.scala')
-rw-r--r-- | test/pending/pos/nothing.scala | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/pending/pos/nothing.scala b/test/pending/pos/nothing.scala new file mode 100644 index 0000000000..f76017fb16 --- /dev/null +++ b/test/pending/pos/nothing.scala @@ -0,0 +1,24 @@ +// More shoddy treatment for nothing. +class A { + class Q3A[+T1, T2 <: T1](x: T1) + class Q3B[+T1, T2 <: T1](x: Q3A[T1, T2]) + + val x1 = new Q3B(new Q3A("a")) + val x2 = new Q3B(new Q3A[String, Nothing]("a")) + val x3 = new Q3B(new Q3A[String, Null]("a")) + // test/pending/pos/nothing.scala:5: error: type mismatch; + // found : A.this.Q3A[String,Nothing] + // required: A.this.Q3A[String,T2] + // Note: Nothing <: T2, but class Q3A is invariant in type T2. + // You may wish to define T2 as +T2 instead. (SLS 4.5) + // val x1 = new Q3B(new Q3A("a")) + // ^ + // test/pending/pos/nothing.scala:6: error: type mismatch; + // found : A.this.Q3A[String,Nothing] + // required: A.this.Q3A[String,T2] + // Note: Nothing <: T2, but class Q3A is invariant in type T2. + // You may wish to define T2 as +T2 instead. (SLS 4.5) + // val x2 = new Q3B(new Q3A[String, Nothing]("a")) + // ^ + // two errors found +} |