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
Contravariance mucks with implicit resolution #2509
Comments
Imported From: https://issues.scala-lang.org/browse/SI-2509?orig=1 |
@adriaanm said: |
@adriaanm said: type inference&implicit search yields: println("A: " + f[A](a)(xa).value)
println("B: " + f[B](b)(xa).value) but that's what's expected because |
Kris Nuttycombe (nuttycom) said: The concepts aren't totally orthogonal; it's more like there should be a distinction between subclassing (where subclasses are always more specific) and subtyping, where an instance of a subtype is always substitutable for an instance of the supertype. |
@paulp said: Discussion: https://groups.google.com/forum/#!topic/scala-language/ZE83TvSWpT4 Implementation: https://github.com/paulp/scala/tree/topic/contrarivariance |
@milessabin said (edited on May 29, 2016 7:56:40 AM UTC): |
@dwijnand said: |
@soc said: |
Tongfei Chen (ctongfei) said: |
Guillaume Martres (Smarter) said (edited on May 30, 2016 4:03:19 PM UTC): |
This is a backport of the following Dotty change to scalac, lampepfl/dotty@8954026 As in the Dotty implementation the specificity comparison which is used for overload resolution and implicit selection is now performed as-if all contravariant positions in top level type constructors were covariant. Currently this breaks test/files/run/t2030.scala in exactly the same way as in Dotty as reported here, lampepfl/dotty#1246 (comment) and in this PR it has been changed to a neg test. However, test/files/run/t2030.scala passes when this PR is combined with, scala#6139 so if/when that is merged it can be switched back to a pos test. Fixes scala/bug#2509. Fixes scala/bug#7768.
This is a backport of the following Dotty change to scalac, lampepfl/dotty@8954026 As in the Dotty implementation the specificity comparison which is used for overload resolution and implicit selection is now performed as-if all contravariant positions in top level type constructors were covariant. Currently this breaks test/files/run/t2030.scala in exactly the same way as in Dotty as reported here, lampepfl/dotty#1246 (comment) and in this PR it has been changed to a neg test. However, test/files/run/t2030.scala passes when this PR is combined with, scala#6139 so if/when that is merged it can be switched back to a pos test. Fixes scala/bug#2509. Fixes scala/bug#7768.
This is a backport of the following Dotty change to scalac, lampepfl/dotty@8954026 As in the Dotty implementation the specificity comparison which is used for overload resolution and implicit selection is now performed as-if all contravariant positions in top level type constructors were covariant. Currently this breaks test/files/run/t2030.scala in exactly the same way as in Dotty as reported here, lampepfl/dotty#1246 (comment) and in this PR it has been changed to a neg test. However, test/files/run/t2030.scala passes when this PR is combined with, scala#6139 so if/when that is merged it can be switched back to a pos test. Fixes scala/bug#2509. Fixes scala/bug#7768.
This is a backport of the following Dotty change to scalac, lampepfl/dotty@8954026 As in the Dotty implementation the specificity comparison which is used for overload resolution and implicit selection is now performed as-if all contravariant positions in top level type constructors were covariant. Currently this breaks test/files/run/t2030.scala in exactly the same way as in Dotty as reported here, lampepfl/dotty#1246 (comment) and in this PR it has been changed to a neg test. However, test/files/run/t2030.scala passes when this PR is combined with, scala#6139 so if/when that is merged it can be switched back to a pos test. Fixes scala/bug#2509. Fixes scala/bug#7768.
This is a backport of the following Dotty change to scalac, lampepfl/dotty@8954026 As in the Dotty implementation the specificity comparison which is used for overload resolution and implicit selection is now performed as-if all contravariant positions in type constructors were covariant. Currently this breaks test/files/run/t2030.scala in exactly the same way as in Dotty as reported here, lampepfl/dotty#1246 (comment) and in this PR it has been changed to a neg test. However, test/files/run/t2030.scala passes when this PR is combined with, scala#6139 so if/when that is merged it can be switched back to a pos test. Fixes scala/bug#2509. Fixes scala/bug#7768.
This is a backport of the following Dotty change to scalac, lampepfl/dotty@8954026 As in the Dotty implementation the specificity comparison which is used for overload resolution and implicit selection is now performed as-if all contravariant positions in type constructors were covariant. Fixes scala/bug#2509. Fixes scala/bug#7768.
A condition under which the most-specific implicit is not being selected:
gives:
Making X invariant in T gives a correct result, but of course is much less flexible.
The text was updated successfully, but these errors were encountered: