I am trying to compile the following code:
class MyClass { def foo(): this.type = Helper.bar(this) } class ChildClass extends MyClass object Helper { def bar[A <: MyClass](cls: A): A = cls }
The resulting compiler error:
type arguments [MyClass.this.type] do not conform to method bar type parameter bounds [A <: MyClass]
Is there anything I can do to make this compilation property using the method signatures above? It seems that MyClass.this.type should be validClass, and I don't want it to be thrown twice when calling the helper (once on the way and once on exit).
source share