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
Regression with type inference and type constructors #7517
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7517?orig=1 |
@paulp said: |
@retronym said: |
@paulp said: |
@paulp said: // test/files/pos/hkrange.scala
class A {
def f[CC[X] <: Traversable[X]](x: CC[Int]) = ()
f(1 to 5)
}
|
@retronym said: |
@retronym said: |
@retronym said: scala/scala@e5da30b843#L5L3176 // old
tpes = List(Composed.this.Split[A], K[[T]A[B[T]]])
//new
tpe.dealiasWidenChain.toList = List(Composed.this.Split[A], K[[T]A[B[T]]]) |
@paulp said: |
@paulp said: - tpe.dealiasWidenChain exists unifySpecific
+ val tpes = if (isLowerBound) tpe.dealiasWidenChain else tpe :: Nil
+ tpes exists unifySpecific |
@paulp said: % qscalac -d /tmp test/files/pos/t6846.scala
test/files/pos/t6846.scala:6: error: polymorphic expression cannot be instantiated to expected type;
found : [M[_], A]Test.Arb[M[A]]
required: Test.Arb[Test.ListInt]
foo: Arb[ListInt]
^
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.ListInt]
bar: Carb[ListInt]
^
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.ListSingletonX]
bar: Carb[ListSingletonX]
^
test/files/pos/t6846.scala:27: error: polymorphic expression cannot be instantiated to expected type;
found : [M[_], A]Test2.Carb[M[A]]
required: Test2.Carb[Test2.ListSingletonY]
bar: Carb[ListSingletonY]
^
four errors found |
@retronym said: Here are all of the before/after pairs. I'm not sure about the difference between the first and second attempt to do the old ad-hoc version of
|
@retronym said (edited on May 28, 2013 9:48:42 PM UTC): -addBound(tp.typeConstructor)
-isSubArgs(lhs, rhs, params, AnyDepth)
+isSubArgs(lhs, rhs, params, AnyDepth) && {addBound(tp.typeConstructor); true} With this patch, both this test and t6846.scala compile. A quick run of What I'm trying to avoid, is registering both type constructors |
@retronym said: I suppose it would be good to try to construct a simpler test that exhibits the same problem to gauge where this lands on the esoteric-o-meter. Paul, perhaps could you discuss this one with Adriaan? |
@JamesIry said (edited on May 29, 2013 8:31:37 PM UTC): |
@adriaanm said: More generally, I think this is a good reminder that we've hit the limit of what we can fix in 2.10.x, especially regarding type checking. |
@retronym said: |
@retronym said: |
@paulp said: |
The following compiles in 2.10.1, but not in 2.10.2-RC1. This has a straightforward workaround (see comments) and is not urgent.
Error:
The text was updated successfully, but these errors were encountered: