【发布时间】:2016-06-27 20:15:52
【问题描述】:
假设我们有以下方法
def func[T <: HList](hlist: T, poly: Poly)
(implicit mapper : Mapper[poly.type, T]): Unit = {
hlist map poly
}
和自定义多边形
object f extends (Set ~>> String) {
def apply[T](s : Set[T]) = s.head.toString
}
所以我可以像这样使用func
func(Set(1, 2) :: Set(3, 4) :: HNil, f)
在我的代码中,我有少量的 Polies 和大量的 func 调用。为此,我尝试将poly: Poly 移动到隐式参数并得到预期的消息
illegal dependent method type: parameter appears in the type of another parameter in the same section or an earlier one
如何更改或扩展poly: Poly 参数以避免此错误(我需要保留类型签名func[T <: HList](...))?
【问题讨论】: