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

Simple, sound upcasts don't happen with -Xstrict-inference #7991

Closed
scabug opened this issue Nov 21, 2013 · 4 comments
Closed

Simple, sound upcasts don't happen with -Xstrict-inference #7991

scabug opened this issue Nov 21, 2013 · 4 comments
Assignees

Comments

@scabug
Copy link

scabug commented Nov 21, 2013

With -Xstrict-inference per #6680:

scala> sealed abstract class IBox[A]
defined class IBox

scala> final case class ICBox[A](a: A) extends IBox[A]
defined class ICBox

scala> def mapbox[A, B](fa: IBox[A])(f: A => B): IBox[B] = fa match {case ICBox(a) => ICBox(f(a))}
<console>:10: error: type mismatch;
 found   : a.type (with underlying type A)
 required: A
       def mapbox[A, B](fa: IBox[A])(f: A => B): IBox[B] = fa match {case ICBox(a) => ICBox(f(a))}
                                                                                              ^

It's great that a has the A from ICBox in this case, but here it's sound to crush it up to A from mapbox at the point I'm using it. Similarly with covariant box:

scala> sealed abstract class Box[+A]
defined class Box

scala> final case class CBox[+A](a: A) extends Box[A]
defined class CBox

scala> def mapbox[A, B](fa: Box[A])(f: A => B): Box[B] = fa match {case CBox(a) => CBox(f(a))}
<console>:10: error: type mismatch;
 found   : a.type (with underlying type A)
 required: A
       def mapbox[A, B](fa: Box[A])(f: A => B): Box[B] = fa match {case CBox(a) => CBox(f(a))}
                                                                                          ^
@scabug
Copy link
Author

scabug commented Nov 21, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7991?orig=1
Reporter: Stephen Compall (s11001001)
Affected Versions: 2.11.0-M7
See #6680

@SethTisue
Copy link
Member

do we still care about -Xstrict-inference?

@SethTisue
Copy link
Member

#6680 (comment):

-Xstrict-inference was intended only as a coarse hacky start, but it kind of coincided with my departure. I expect it is overflowing with implementation issues.

@SethTisue
Copy link
Member

scala/scala#6593

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

3 participants