Here is the minimal reproduction of my problem:
trait Superclass[T]
class A(val key: Any) extends Superclass[key.type]
val x: Superclass["123"] = A("123")
As you can see, I'm trying to encode the statically known type of Key into the type parameter.
It's not like I can put the type of key
as a type parameter of A, since in my real example, it's more like class A(using g: blablah)(val key: g.Key) extends SuperClass[g.Mapping[key.type]]
but that's not relevant for the problem above.
Is it just that we can't use dependent types inside the arguments of the super class?
Update
The encoding with type members yields the same error:
trait Superclass {
type T
}
class A(val key: Any) extends Superclass {
type T = key.type
}
val x: Superclass & {type T = "123"} = A("123")
I still get
[error] 14 | val x: Superclass & {type T = "123"} = A("123")
[error] | ^^^^^^^^
[error] | Found: Main.A
[error] | Required: Main.Superclass & Object{T = ("123" : String)}