私は操作可能なタイプを定義しています:
trait Operable {
def +[A](other: A)(implicit evidence: this.type =:= A): this.type
def -[A](other: A)(implicit evidence: this.type =:= A): this.type
def *[A](other: Float): this.type
}
/** Position descriptions */
trait Pos[T <: Operable] {
def eval: T
}
def test[T <: Operable](x1: Pos[T], x2: Pos[T]): T = {
x2.eval - x1.eval
}
そして、次のコンパイル時エラーが発生します。
Cannot prove that _1.type =:= T.
コンパイラが型の等価性を証明できないのはなぜですか? また、この問題を解決するにはどうすればよいですか? x1 と x2 の T パラメータは同じでなければなりません。そうでないのはなぜですか?