-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[CSSyntaticElement] Desugar types before collecting "in scope" type v… #65048
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
…ariables Generic type aliases, unless desugared, could bring unrelated type variables into the scope i.e. `TypeAlias<$T, $U>.Context` is actually `_Context<$U>`. These variables could be inferrable only after the the body the closure is solved. To avoid that, let's adjust `TypeVariableRefFinder` to desugar types before collecting referenced type variables. Resolves: rdar://107835060
@swift-ci please test |
// For example `Typealias<$T, $U>.Context` which desugars into | ||
// `_Context<$U>` would bring in `$T` that could be inferrable | ||
// only after the body of the closure is solved. | ||
type = type->getDesugaredType(); |
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.
I think getDesugaredType() only unwraps one level of sugar, but you might have type aliases in nested position. Maybe you should use getCanonicalType() instead? Are other callers of getTypeVariables() also affected by this? Perhaps getTypeVariables() should canonicalize the type itself first.
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.
Other callers of getTypeVariables()
don't really care because only closures are solved in isolation.
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.
Indeed, getDesugaredType would only unwrap N levels of sugar if they occur in sequence... I'll switch this to getCanonicalType()
.
…riables Follow-up to swiftlang#65048 `getDesugaredType` unwraps sugar types that appear in sequence, to remove sugar from nested positions we need to get a canonical type. Thanks to @slavapestov for pointing it out.
…riables Follow-up to swiftlang#65048 `getDesugaredType` unwraps sugar types that appear in sequence, to remove sugar from nested positions we need to get a canonical type. Thanks to @slavapestov for pointing it out.
…riables Follow-up to swiftlang#65048 `getDesugaredType` unwraps sugar types that appear in sequence, to remove sugar from nested positions we need to get a canonical type. Thanks to @slavapestov for pointing it out.
…ariables
Generic type aliases, unless desugared, could bring unrelated type variables into the scope i.e.
TypeAlias<$T, $U>.Context
is actually_Context<$U>
. These variables could be inferrableonly after the the body the closure is solved. To avoid that, let's adjust
TypeVariableRefFinder
to desugar types before collecting referenced type variables.
Resolves: rdar://107835060