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
@paulp said:
To make up for this, I threw in this one:
objectTest2 {
importscala.collection.immutable.ListclassCarb[+_]
implicitdefbar[M[_], A]:Carb[M[A]] =nulltypeListInt=List[Int]
valx:List[Int] =List(1)
valy:ListInt=List(1)
typeListSingletonX= x.typetypeListSingletonY= y.typebar: Carb[List[Int]]
bar: Carb[ListInt]
bar: Carb[ListSingletonX]
bar: Carb[ListSingletonY]
}
Compiles with my imminent pull request, in 2.9 did this:
scalac29 -d /tmp test/files/pos/t6846.scala
test/files/pos/t6846.scala:25: error: polymorphic expression cannot be instantiated to expected type;
found : [M[_], A]Test2.Carb[M[A]]
required: Test2.Carb[Test2.ListSingletonX]
bar: Carb[ListSingletonX]
^
test/files/pos/t6846.scala:26: error: polymorphic expression cannot be instantiated to expected type;
found : [M[_], A]Test2.Carb[M[A]]
required: Test2.Carb[Test2.ListSingletonY]
bar: Carb[ListSingletonY]
^
two errors found
@paulp said:
Oh, but I see now that type constructor inference is useless when combined variance - it appears to always choose Any/Nothing for the type argument if it can. Oh, in that case the invariant version is actually failing in the correct way. The 2.9 version also fails, but for the wrong reason.
test/files/pos/t6846.scala:25:error: typemismatch;
found : Test2.Carb[List[Int]]
required: Test2.Carb[Test2.ListSingletonX]
Note:List[Int] >:Test2.ListSingletonX, but classCarb is invariant in type_.
You may wish to define _ as -_ instead. (SLS4.5)
bar: Carb[ListSingletonX]
^
test/files/pos/t6846.scala:26:error: typemismatch;
found : Test2.Carb[List[Int]]
required: Test2.Carb[Test2.ListSingletonY]
Note:List[Int] >:Test2.ListSingletonY, but classCarb is invariant in type_.
You may wish to define _ as -_ instead. (SLS4.5)
bar: Carb[ListSingletonY]
^
two errors found
The text was updated successfully, but these errors were encountered: