Transitivity of upper limit constraints in scala type checking

I am experimenting with type-level programming in Scala. I think the following code should introduce a check,

trait T[X] {
  type t <: X
}

trait A[X, e <: T[T[X]]] extends T[X] {
  final type t  = e # t # t
}

      

but I keep getting the following error like:

error: overriding type t in trait T with bounds <: X;
 type t has incompatible type
       trait A[X, e <: T[T[X]]] extends T[X] { final type t  = e # t # t }
                                                          ^
Nothing <: A.this.t?
true
A.this.t <: X?
false

      

I suppose the restriction type t <: X

in value T

should force e#t <: T[X]

and therefore e#t#t <: X

. I am wrong?

+3


source to share





All Articles