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
scala typechecking type-level-computation


source to share


No one has answered this question yet

Check out similar questions:

27
Why can't a class extend traits with a method of the same signature?
12
Determining Implicit View Boundaries Based on Scala Features
nine
Unable to override type with unstable upper bound
8
How to express type constraints for a higher type type
7
Understanding "type argument arguments does not conform to type parameter constraints" in Scala
2
Scala: implementing the results of a Java interface in an incompatible type
2
Scala: Mixing traits with "same" abstract type element
1
Creating a typed collection
1
How to check for type of equality at level level in scala?
1
What does "do not match the bounds of Builder trait type parameters" in scala?



All Articles
Loading...
X
Show
Funny
Dev
Pics