Skip to content

[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

Merged
merged 1 commit into from
May 30, 2019

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented May 29, 2019

To print mangling names. Otherwise, they hit assertion:

Assertion failed: (!Ty->hasArchetype() && "cannot have contextless archetypes mangled.")

rdar://problem/51198887
rdar://problem/51227338

@rintaro
Copy link
Member Author

rintaro commented May 29, 2019

@swift-ci Please smoke test

@rintaro rintaro requested a review from benlangmuir May 29, 2019 23:21
@benlangmuir benlangmuir requested a review from slavapestov May 29, 2019 23:28
Copy link
Contributor

@slavapestov slavapestov left a 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();
Copy link
Contributor

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.

Copy link
Member Author

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?)

Copy link
Contributor

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.

Copy link
Member Author

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())
Copy link
Contributor

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?

Copy link
Member Author

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 😞

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha.

@rintaro rintaro force-pushed the ide-mangledtype-rdar51198887 branch from e5aa87b to 04cb15c Compare May 30, 2019 00:03
@rintaro
Copy link
Member Author

rintaro commented May 30, 2019

@swift-ci Please smoke test

To print mangling names.

rdar://problem/51198887
rdar://problem/51227338
@rintaro rintaro force-pushed the ide-mangledtype-rdar51198887 branch from 04cb15c to 5ff4b0c Compare May 30, 2019 17:59
@rintaro
Copy link
Member Author

rintaro commented May 30, 2019

@swift-ci Please smoke test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants