我很难定义以下类型类:
@typeclass trait ElementIterator[It[_]] {
def record[Item[Element], Element <: ElementT, Ctx >: Context[ElementT]]
(iterator: It[Item[Element]],
name: String,
what: RefExpr[Ctx, Any])
(implicit ctxLike: ContextLike[Item],
withVariables: WithVariables[Item[Element]]
): It[Item[Element]]
}
我收到以下错误:
Error:(11, 4) type mismatch;
found : sre.task.Core.WithVariables[Item[A]]
required: sre.task.Core.WithVariables[Item[Element]]
Note: implicit value elementIteratorForIterator is not applicable here because it comes after the application point and it lacks an explicit result type
@typeclass trait ElementIterator[It[_]] {
我不确定这里会发生什么。在我看来,在隐式参数列表中使用Element
时,它将被新分配给新的类型变量A
,而不是将其与iterator
类型的变量匹配。
我真正想要的是WithVariables
具有与It
相同的类型参数。
这里到底发生了什么?这是一个错误吗?
答案 0 :(得分:2)
这很可能是对模拟物的限制。考虑在github上提交错误报告。
解决方法是禁用@typeclass trait ElementIterator[It[_]] {
@noop def record[Item[Element], Element <: ElementT, Ctx >: Context[ElementT]]
(iterator: It[Item[Element]],
name: String,
what: RefExpr[Ctx, Any])
(implicit ctxLike: ContextLike[Item],
withVariables: WithVariables[Item[Element]]
): It[Item[Element]]
}
的生成。
$('#featured-top .option').click(function(){
// Use this way:
$(this).find('a').html('Close');
// If you wanna change this as well, you can use:
$(this).closest("#featured-top").find('.featured-content').slideToggle();
});