【发布时间】:2018-08-01 09:04:16
【问题描述】:
我有:
trait A[B[_]]
我有:
trait Base {
type AImpl <: ???
def foo: AImpl
}
这样扩展 Base 的类将定义 A 并实现方法和字段。即:
trait BB[T]
trait AA extends A[BB]
trait Child extends Base {
override type AImpl = AA
}
我的问题是声明抽象类型AImpl。我试过了:
type AImpl <: A[B[_]] forSome {type B[_]}
但我收到以下编译错误:
B[_] takes no type parameters, expected: one
type AImpl <: A[B[_],_] forSome {type B[_]}
声明这种抽象类型的正确方法是什么?
【问题讨论】:
-
这不可能是你想要的。具体来说,您可能还想让
AImpl更友好。
标签: scala parametric-polymorphism abstract-type