The following Scala code fails to compile in Scala 2.7.7, with a type mismatch error "found: Null(null) required: T" on the last line:
/**
* @param [T] key type
*/
class Key[T]
class Entry[T](val k: Key[T], val v: T)
def makeEntry[T <: AnyRef] = new Entry[T](new Key[T], null)
I'm fully aware of the evilness of nulls, but suffice it to say that I actually need to do this. Is this a compiler bug or programmer error?
Edit: Just to clarify, T is a type parameter and not a concrete type. I didn't realize this was ambiguous in the original question until I read Carl's response more carefully.