Why certain type projections are rejected and slightly different not?

五迷三道 提交于 2019-12-21 05:17:10

问题


Sorry for non-descriptive title. Typelevel computation are not too common theme in the internet to establish precise terms.

I tried to use typelevel computations and suddenly get spurious errors every here and there. I just could not comprehend why so little difference matters. I managed to forge another concise example:

trait Sample {
  type X
  type DX[I <: X] <: Nothing
  type EX[I <: X] = Nothing
}
type Aux[I] = Sample {type X = I}

type U1 = Aux[Int]#DX[Int] // ok
type U2 = Aux[Int]#EX[Int] // fails

The error message is:

error: type arguments [Int] do not conform to type EX's type parameter bounds [I <: Sample.this.X]
type U2 = Aux[Int]#EX[Int]
                   ^

But the EX and DX had the same type parameter bounds. Why it is right in one case and wrong in the another?

来源:https://stackoverflow.com/questions/45767714/why-certain-type-projections-are-rejected-and-slightly-different-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!