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
[Mangling] Several fixes for de/re/-mangling of generic typealiases #17509
Conversation
@swift-ci please smoke test |
@swift-ci please test source compatibility |
@@ -11,3 +11,4 @@ $SSayypXpG ---> Array<Any.Type> | |||
$S12EyeCandyCore11XPCListenerC14messageHandleryyAA13XPCConnectionV_AA10XPCMessageVxtcvpfiyAF_AHxtcfU_TA.4 ---> Can't resolve type of $S12EyeCandyCore11XPCListenerC14messageHandleryyAA13XPCConnectionV_AA10XPCMessageVxtcvpfiyAF_AHxtcfU_TA.4 | |||
$Ss10CollectionP7ElementQa ---> Can't resolve type of $Ss10CollectionP7ElementQa | |||
$S12TypeReconstr8patatinoayAA5tinkyVGSgD ---> Optional<patatino> | |||
$S12TypeReconstr5OuterV3Fooayx_SiGD ---> Can't resolve type of $S12TypeReconstr5OuterV3Fooayx_SiGD |
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.
Why is this invalid?
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 is a hack to avoid crashing; a more complete fix requires deeper changes to the type reconstruction logic."
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.
We need to do the thing where we pull out all of the generic argument lists from the "parent" type and put them together.
lib/IDE/TypeReconstruction.cpp
Outdated
return; | ||
|
||
auto *genericTypeAlias = | ||
cast<TypeAliasDecl>(generic_type_result._decls.front()); | ||
GenericSignature *signature = genericTypeAlias->getGenericSignature(); | ||
if (template_types_result._types.size() != signature->getGenericParams().size()) |
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 could (maybe) set an error instead of silently returning (result.error
).
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.
Good point.
@@ -254,6 +257,10 @@ int main(int argc, char **argv) { | |||
Invocation.setModuleName("lldbtest"); | |||
Invocation.getClangImporterOptions().ModuleCachePath = ModuleCachePath; | |||
|
|||
if (!ResourceDir.empty()) { | |||
Invocation.setRuntimeResourcePath(ResourceDir); |
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.
Do you need this for testing? [If so, can you add a test for this].
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.
It's for debugging: I often use a Debug compiler with a standard library that was build with a Release+Asserts compiler, because the latter builds the standard library so much faster. Testing doesn't need this.
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.
OK, makes sense, thanks!
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 don't know mangling well enough to comment but the type reconstruction changes look reasonable to me (modulo minors).
We need to look through a Type node before trying the standard substitutions.
The mangling of generic typealiases was using the underlying type’s generic arguments rather than the generic arguments for the typealias itself. Directly encode the generic arguments from the substitution map instead. Also address some related issues with remangling generic typealiases. Fixes rdar://problem/41444286.
…ealias. When we are attempting to reconstruct a type node for a generic typealias, make sure that we get the right number of generic arguments. If not, fail gracefully rather than crashing. Eventually, we should be able to handle this nested case.
b4c0f89
to
15f4ee7
Compare
@swift-ci please smoke test |
@swift-ci please test source compatibility |
@swift-ci please smoke test |
@swift-ci please test source compatibility |
@swift-ci please smoke test and merge |
1 similar comment
@swift-ci please smoke test and merge |
Introduce several fixes for mangling and remangling of generic typealiases:
Should fix rdar://problem/41444286