Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not support constrait on this.type #65

Open
Atry opened this issue Aug 23, 2016 · 1 comment
Open

Does not support constrait on this.type #65

Atry opened this issue Aug 23, 2016 · 1 comment

Comments

@Atry
Copy link

Atry commented Aug 23, 2016

@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 {
 ^
@Atry
Copy link
Author

Atry commented Aug 23, 2016

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 =>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant