-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Regression: type inference involving higher-kinded types and upper-bounds #9676
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
Comments
We don't even need implicit search to reproduce the problem: object Test {
trait SubtypeOf[A[_], B[_]]
def instance[G[_], F[a] <: G[a]]: SubtypeOf[F, G] = new SubtypeOf[F, G] {}
val x: SubtypeOf[List, Seq] = instance // error
} |
It looks like our handling of constraints on higher-kinded type variable is incomplete, when we typecheck Constraint(
uninstVars = G, F;
constrained types = [G[_$3], F[a] <: G[a]] => SubtypeOf[F, G]
bounds =
G[_$3]
F[a] <: G[a]
ordering =
) Notice that Constraint(
uninstVars = G, F;
constrained types = [G, F <: G] => SubtypeOf[F, G]
bounds =
G
F
ordering =
F <: G
)
|
If `?F <: [X] => ?G[X]`, then the ordering part of the constraint should record `?F <: ?G`, otherwise constraints won't be propagated correctly. It's not clear to me if we should make a similar change in `stripParams` but note that doing so would require being a bit careful: since we use the upper bound of a type variable to determine its kind, we can't just replace it by `[X] => ?G[X]` by `AnyKind`. Fixes scala#9676.
If `?F <: [X] => ?G[X]`, then the ordering part of the constraint should record `?F <: ?G`, otherwise constraints won't be propagated correctly. It's not clear to me if we should make a similar change in `stripParams` but note that doing so would require being a bit careful: since we use the upper bound of a type variable to determine its kind, we can't just replace it by `[X] => ?G[X]` by `AnyKind`. Fixes scala#9676.
Minimized code
Output
Expectation
Implicit resolution works in both cases.
The text was updated successfully, but these errors were encountered: