Assume, we have an abstract class with an abstract type field:
abstract class A {type T}
Now let\'s assume, we have a method, which returns
You can use the <%< which tells you in compile-time if two types are compatible.
scala> class A { type T }
defined class A
scala> implicitly[A { type T=String } <%< A { type T=Int } ]
:9: error: could not find implicit value for parameter e: <%<[A{type T = String},A{type T = Int}]
implicitly[A { type T=String } <%< A { type T=Int } ]
^
scala> implicitly[A { type T=String } <%< A { type T=String } ]
res1: <%<[A{type T = String},A{type T = String}] =
scala> implicitly[A { type T=String } <%< A ]
res3: <%<[A{type T = String},A] =