Open
Description
Happening in Scala 2.7.1 and 2.7.2 at least:
scala> trait Test[A]
defined trait Test
scala> trait Test2[+A]
defined trait Test2
scala> def f[A](a:Test[A]):Test[A] = null
f: [A](Test[A])Test[A]
scala> def f2[A](a:Test[A]):Test2[A] = null
f2: [A](Test[A])Test2[A]
scala> val x:Test[Nothing] = null
x: Test[Nothing] = null
scala> f(x)
<console>:8: error: type mismatch;
found : Test[Nothing]
required: Test[A]
f(x)
^
scala> f[Nothing](x)
res2: Test[Nothing] = null
scala> f2(x)
res1: Test2[Nothing] = null
This happens only for A=Nothing. And only if the return type is invariant in a type variable being Nothing. There is probably not much sense in operating on Nothing types, but what is the rationale behind this behaviour?