【发布时间】:2017-10-25 21:05:30
【问题描述】:
我在编写可以从其发起者那里获取和传递抽象类型成员的代理时遇到问题。
trait Holder[A[_]] {
type I
type Y <: A[I]
}
trait Proxy[A[_], H <: Holder[A]] extends Holder[A] {
override type I = H#I
override type Y = H#Y
}
我得到了错误:
error: overriding type Y in trait Holder with bounds <: A[Proxy.this.I];
type Y has incompatible type
override type Y = H#Y
^
one error found
这是一个基本的 scala 限制,还是可以以某种方式规避?
【问题讨论】:
-
我想你的意思是
override type Y = A[I]? -
不。我想将类型从发起者对象传递给代理。所以我可以使用根据发起者类型定义的方法
标签: scala type-projection