当我在尝试抽象类时,我偶然发现了这个问题.以下代码:
import shapeless._ class A [tuple <: Product,hlist <: HList] (tuple: tuple) (implicit tupleGeneric: Generic.Aux[tuple,hlist]) { private val hlist = tupleGeneric.to(tuple) println(hlist) } new A((1,'b')) {}
无法使用以下消息进行编译:
could not find implicit value for parameter tupleGeneric: shapeless.Generic.Aux[(Int,Char),shapeless.::[Int,shapeless.::[Char,shapeless.HNil]]] new A((1,'b')) {} ^
但是,如果我只是从新的A((1,’b’)){}删除{}部分,它会发现隐式没有问题.
这是Scala的错误还是我错过了什么?
解决方法
事实证明这是一个公认的错误.