scala> class A { type T <: String; def f(a: T) = println("foo")}
defined class A
scala> (new A).f("bar")
<console>:9: error: type mismatch;
found : java.lang.String("bar")
required: _1.T where val _1: A
(new A).f("bar")
^
Class A
has an abstract type T
, but is not an abstract class. Creating an object of A
(as shown) does not define type T
.
My first thought was, I am allowed to pass any type as T
which is a subclass of String, but I am not. So what type actually is T
in the object and what am I allowed to pass through ?