这是一个简单的例子:
trait Proposition[T] {
type Repr = T
}
trait Scope {
type OUT
type Consequent = Proposition[_ <: OUT]
abstract class Proof[-I, +P <: Consequent] {
final def instanceFor(v: I): P#Repr = ???
final def apply(v: I): P#Repr = instanceFor(v)
}
}
这给出了编译错误:
[Error] ....scala:44: type mismatch;
found : _$1(in type Consequent)
required: (some other)_$1(in type Consequent)
这(some other)
是从哪里来的?它是由明确的类型选择规则引起的编译器错误(理论上应该在 scala 3 中解决)?
更新 1对不起,我刚刚意识到P#Repr
不应该称为类型选择,它应该只指val p: P;p.Repr
,现在它增加了更多的混乱,因为:
我什至不知道这个语法的名字,但我一直在使用它
它甚至没有在 DOT 微积分中定义。所以scala 3的支持是有问题的