-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[TypeContextInfo/ConformingMethods] Map type out of context #25130
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
[TypeContextInfo/ConformingMethods] Map type out of context #25130
Conversation
@swift-ci Please smoke test |
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 looks good, of course it’s unfortunate we have this representational issue in the first place. Depending on how motivated you feel I have two optional suggestions
@@ -87,6 +87,10 @@ void ConformingMethodListCallbacks::doneParsing() { | |||
if (!T || T->is<ErrorType>() || T->is<UnresolvedType>()) | |||
return; | |||
|
|||
T = T->getRValueType(); | |||
if (T->hasArchetype()) | |||
T = T->mapTypeOutOfContext(); |
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.
If the hasArchetype() check is an optimization, you don’t really need it because mapTypeOutOfContext() should already short circuit in this case. If it’s because you might have archetypes or type parameters here, it’s worth untangling that. I would try making it unconditional and seeing if the tests pass.
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 it's safe to check this, just in case it have hasTypeParameter()
. (There's is an invariant that hasArchetype()
and hasTypeParameter()
are mutually exclusive, right?)
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.
Nothing enforces they're mututally exclusive, that's the problem. This is why I like to establish the invariant by using mapTypeIntoContext()/OutOfContext() unconditionally where possible, and fixing callers to only pass one or the other consistently.
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 understand. Let me try that in followups.
T = env->mapTypeIntoContext(T); | ||
|
||
T = T->getRValueType(); | ||
if (T->hasArchetype()) |
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.
Is this ever true? In the old code we would map into context unconditionally. Or is env always null?
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.
Yes, it just used to lack tests for generic environment 😞
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.
Gotcha.
e5aa87b
to
04cb15c
Compare
@swift-ci Please smoke test |
To print mangling names. rdar://problem/51198887 rdar://problem/51227338
04cb15c
to
5ff4b0c
Compare
@swift-ci Please smoke test |
To print mangling names. Otherwise, they hit assertion:
rdar://problem/51198887
rdar://problem/51227338