Skip to content

Instantly share code, notes, and snippets.

@mpilquist
Last active November 28, 2017 15:19
Show Gist options
  • Save mpilquist/b89a5fa05a480774d280e9c6aa999d97 to your computer and use it in GitHub Desktop.
Save mpilquist/b89a5fa05a480774d280e9c6aa999d97 to your computer and use it in GitHub Desktop.
Type inference issue
object Example {
trait H[A]
def id[A]: H[A] => H[A] = in => in
def apply[A,B](h: H[A], f: H[A] => H[B]): H[B] = f(h)
def applyIdExplicitType[A](h: H[A]): H[A] = apply(h, id)
// Fails in 2.11,2.12,2.13-M2, works in Dotty
// found : Example.H[Nothing] => Example.H[Nothing]
// required: Example.H[A] => Example.H[B]
def applyIdInferredType[A](h: H[A]) = apply(h, id)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment