You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scala>sealedabstractclassIBox[A]
defined classIBox
scala>finalcaseclassICBox[A](a: A) extendsIBox[A]
defined classICBox
scala>defmapbox[A, B](fa: IBox[A])(f: A=>B):IBox[B] = fa match {caseICBox(a) =>ICBox(f(a))}
<console>:10:error: typemismatch;
found : a.type (with underlying typeA)
required: Adefmapbox[A, B](fa: IBox[A])(f: A=>B):IBox[B] = fa match {caseICBox(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>sealedabstractclassBox[+A]
defined classBox
scala>finalcaseclassCBox[+A](a: A) extendsBox[A]
defined classCBox
scala>defmapbox[A, B](fa: Box[A])(f: A=>B):Box[B] = fa match {caseCBox(a) =>CBox(f(a))}
<console>:10:error: typemismatch;
found : a.type (with underlying typeA)
required: Adefmapbox[A, B](fa: Box[A])(f: A=>B):Box[B] = fa match {caseCBox(a) =>CBox(f(a))}
^
The text was updated successfully, but these errors were encountered:
-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.
With
-Xstrict-inference
per #6680:It's great that
a
has theA
fromICBox
in this case, but here it's sound to crush it up toA
frommapbox
at the point I'm using it. Similarly with covariant box:The text was updated successfully, but these errors were encountered: