在中使方法泛型
T
让人摸不着头脑
是如果
processCaseClass
不知道是什么
KV
,它没有机会对其结构进行足够的分析,以做出
LabelledGeneric[KV]
,产生隐式分辨率错误。通过使其成为隐式参数,您可以转移生成
LabelledGeneric
PK
是
你的第一个定义是
def processCaseClass[KV <: Product, L <: HList](p: KV): Any // Signature of pCC
// Function body doesn't affect sig., aside from return type, so what you write is what you get
// A sig. is the only interface between a method and the world. This method doesn't
// say there's a relationship between KV and L in its signature, so there doesn't
// need to be one.
// Instantiate KV = (Int, Int), L = String :: String :: HNil, p = (5, 5)
val x = processCaseClass[(Int, Int), String :: String :: HNil]((5, 5))
// Perfectly valid to the compiler... but what is this supposed to do?