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

Compiler error when using type constraint #115

Open
ssanj opened this issue Oct 31, 2018 · 0 comments
Open

Compiler error when using type constraint #115

ssanj opened this issue Oct 31, 2018 · 0 comments

Comments

@ssanj
Copy link

ssanj commented Oct 31, 2018

Hi,

If I try and use Simulcrum on the following:

@typeclass trait Functor[F[_]] { self =>
  def map[A, B](fa: F[A])(f: A => B): F[B]

  def widen[A, B >: A](fa: F[A]): F[B] = fa.asInstanceOf[F[B]]

  def xyz[A, B](ff: F[A => B])(a: A): F[B]
}

I get a compiler error:

<pastie>:18: error: not found: type A
  def widen[A, B >: A](fa: F[A]): F[B] = fa.asInstanceOf[F[B]]
                    ^
<pastie>:15: error: type arguments [C,B] do not conform to method widen's type parameter bounds [A,B >: A]
@typeclass trait Functor[F[_]] { self =>
 ^

If I rewrite widen not to use a type bound:

@typeclass trait Functor[F[_]] { self =>
  def map[A, B](fa: F[A])(f: A => B): F[B]

  def widen[A, B](fa: F[A])(implicit ev: A <:< B): F[B] = fa.asInstanceOf[F[B]]

  def xyz[A, B](ff: F[A => B])(a: A): F[B]
}

then I don't get any compilation errors.

Am I using Simulcrum incorrectly or is this a bug?

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