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

Comments

@scabug
Copy link

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Author

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
1 participant
You can’t perform that action at this time.