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

Unexpected compiler error involving type lambda and implicit conversion #5993

Closed
scabug opened this issue Jun 28, 2012 · 2 comments
Closed

Comments

@scabug
Copy link

scabug commented Jun 28, 2012

class LambdasAndImplicits {

  class MA[M[_], A](ma: M[A]) {
    def sheep = ma + " bee"
  }

  implicit def asMA[M[_], A](ma: M[A]) = new MA[M, A](ma)

  // Fails as expected:
//  (Right(1): Either[String, Int]).sheep

  // The two types are equal
  type Maybe[A] = Either[String, A]
  type MaybeLambda[A] = ({type l[x] = Either[String, x]})#l[A]

  val a = (Right(1).asInstanceOf[Maybe[Int]]).sheep
  val b = (Right(1).asInstanceOf[MaybeLambda[Int]]).sheep
  // Fails unexpectedly
  val c = (Right(1).asInstanceOf[({type l[x] = Either[String, x]})#l[Int]]).sheep

}

I would expect b and c to evaluate to the same result, however there seems to be some difference in handling a type alias and a type lambda?

@scabug
Copy link
Author

scabug commented Jun 28, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5993?orig=1
Reporter: Robin Palotai (ron)
Affected Versions: 2.9.2

@scabug
Copy link
Author

scabug commented Jul 2, 2012

@adriaanm said:
this is a limitation of type constructor inference

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

No branches or pull requests

1 participant