-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #5844: Use an approximating type map to substitute parent type params #5899
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a bit restrictive to me, e.g. the following works in Scala 2:
trait A
trait B[X]{
def m(): X
}
trait C[X] extends B[X with A]
object O{
def m(c: C[_]) = {
val x: A = c.m()
}
}
But will fail with this PR. I think we could preserve this by normalizing like this:
X & _ ~> X
X | _ ~> _
Thinking about it more, this seems like a job for |
…pe params Actual arguments could be wildcards, which means a normal substitution will not work.
@@ -195,4 +195,28 @@ trait Substituters { this: Context => | |||
final class SubstParamsMap(from: BindingType, to: List[Type]) extends DeepTypeMap { | |||
def apply(tp: Type): Type = substParams(tp, from, to, this) | |||
} | |||
|
|||
/** An approximating substitution that can handle wildcards in the `to` list */ | |||
final class SubstApproxMap(from: List[Symbol], to: List[Type])(implicit ctx: Context) extends ApproximatingTypeMap { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regular SubstBindingMap
also extends DeepTypeMap
, does this matter here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we do not need to substitute ClassInfos here.
Co-Authored-By: odersky <[email protected]>
Actual arguments could be wildcards, which means a normal substitution will not work.