simulacrum
simulacrum copied to clipboard
Does not support constrait on this.type
@simulacrum.typeclass trait MyTypeClass[A] extends AnyRef {
def opWithThisType(a: A)(implicit constrait: this.type <:< Product) = a
}
/private/tmp/thistype/MyTypeClass.scala:1: type mismatch;
found : <:<[Ops.this.type,Product]
required: <:<[Ops.this.typeClassInstance.type,Product]
@simulacrum.typeclass trait MyTypeClass[A] extends AnyRef {
^
I found a workaround:
@simulacrum.typeclass trait MyTypeClass[A] extends AnyRef { typeClassInstance =>
def opWithThisType(a: A)(implicit constrait: typeClassInstance.type <:< Product) = a
}
Note the self type typeClassInstance =>