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
Failure to find implicit parameterized with F-bound #9764
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9764?orig=1 |
@retronym said: The error in this ticket is:
Which miminizes the problem to: object Test {
trait A[-T]
trait B[-T]
class C extends B[C]
def AfromB[T <: B[T]]: A[T] = null
AfromB : A[C]
} |
@retronym said: I guess this is to avoid having type vars on LHS and RHS of a subtyping check. Dotty typechecks this as: Test.AfromB[Test.C']: Test.A[Test.C] How does it come to this solution? Is C really the maximal type in the range |
@retronym said: |
@retronym said: I see now that the key difference in inference is that scalac solves for T in By that time, T has the constraints:
Given that the T does not appear in the type of this expression, dotc instantiates it to its lower bound, C. This differs from scalac, which would have picked the upper bound (had it not been cyclic), given that T was in a contravariant position. |
@retronym said: object Test {
trait A[-T]
trait B[-T]
class C extends B[C]
def AfromB[T <: B[_]]: A[T] = null
AfromB : A[C]
}
scalac: (Test.this.AfromB[Test.B[_]]: Test.A[Test.C]) dotc: Test.AfromB[Test.C']: Test.A[Test.C] |
Someone should add the "fixed in dotty" label for this issue |
The type-checker fails to find an implicit definition that has an F-bounded type parameter.
Here's a minimized example:
Dotty compiles this OK. The example came up in an attempt to provide multiversal equality for Scala.
The text was updated successfully, but these errors were encountered: