You probably don't need this type parameter in a method foo. The problem is that it obscures the parameter type of this attribute foo, but it is not the same.
object FooInt extends Foo[Int] {
def foo[Int] = 0
// ^ This is a type parameter named Int, not Int the class.
}
Similarly
trait Foo[T] { def foo[T]: T }
^ not the ^
same T
You should simply delete it:
trait Foo[T] { def foo: T }
object FooInt extends Foo[Int] { def foo = 0 }
source
share