class A has one type parameter, but type B has one

前端 未结 2 595
傲寒
傲寒 2021-02-12 22:34

Recently I stumbled across a strange (to me) compiler error message. Consider the following code:

trait Foo {
  type Res <: Foo
  type Bar[X <: Res]
}

cla         


        
2条回答
  •  面向向阳花
    2021-02-12 22:48

    I only have a vague understanding of the exact workings of the type inferrer in Scala so consider this ideas not definitive answers.

    1. Type inferring has problems with inferring more then one type at once.

    2. You use an existential type in the definition of FOO, which translates to: there exists a type such, not sure if this is compatible with the specific type given in MyFoo

提交回复
热议问题