Open
Description
Compiler version
3.4.2
Minimized code
trait P:
type Q
type Qaux[QQ] = P { type Q = QQ }
type QP[P] = P match
case Qaux[q] => q
trait PString extends P:
type Q = String
trait User[X <: P]:
def get(x: X): QP[x.type]
def use(f: (x: X) => QP[x.type] => String): String
class StringUser extends User[PString]:
def get(x: PString): QP[x.type] = ???
def use(f: (x: PString) => QP[x.type] => String): String = ???
Output
-- Error: test.scala:16:6 ------------------------------------------------------
16 |class StringUser extends User[PString]:
| ^
|class StringUser needs to be abstract, since def use(f: (x: X) => QP[x.type] => String): String in trait User is not defined
|(Note that
| parameter (x: X) => QP[x.type] => String in def use(f: (x: X) => QP[x.type] => String): String in trait User does not match
| parameter (x: PString) => String => String in def use(f: (x: PString) => String => String): String in class StringUser
| )
1 error found
Expectation
The compiler should realize that the two function types are exactly the result of replacing the type parameter X with the type PString
, as it does for the non-function type in get
.