I want to use an abstract type rather than a type parameter.
In my generic classes constructor, I want to have a parameter of the generic type, but the code doesn't compile:
class SomeOtherClass(val s: S){
type S
}
The scala compiler error is "not found: type S"
If I use a type parameter instead of an abstract type, then it works:
class SomeClass[T](val t: T){
//...
}
Does scala force me to use a type parameter rather than an abstract type, if I want to have a generic parameter in the constructor?
Is there another way to do this?
new SomeClass(5.asInstanceOf[SomeClass#S]) {type S = Int}
. Note that there is no safety, S is still undefined at the cast. – Squirrel