Skip to content

[ModuleInterface] Print full type if ambiguous for extensions. #37879

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

Conversation

varungandhi-apple
Copy link
Contributor

Fixes rdar://79093752.

Not sure why Options.FullyQualifiedTypesIfAmbiguous was set to false in the first place (I would think that setting should always be true apart from debugging?).

@varungandhi-apple
Copy link
Contributor Author

@swift-ci smoke test

@varungandhi-apple
Copy link
Contributor Author

Okay, this breaks IDE tests because more things start getting qualified... trying to figure out a different solution...

@slavapestov
Copy link
Contributor

I believe there's a way to set PrintOptions specifically for printing module interfaces which doesn't affect the IDE tests. I agree that the extended type should always be fully qualified in module interfaces, just like we fully qualify TypeReprs in other contexts as well.

@varungandhi-apple varungandhi-apple force-pushed the vg-fix-interface-bug branch 3 times, most recently from 5226e3a to 3a00f44 Compare June 11, 2021 08:17
@varungandhi-apple
Copy link
Contributor Author

One of the things need to make this work is to remove the forced = false; in printExtendedTypeName and one more function (so that any changes in printSwiftInterfaceFile would propagate correctly). However, the problem with doing that is that the IDE setting for FullyQualifiedTypesIfAmbiguous + weak ambiguity detection means that the IDE output still ended up changing (presumably, that's why the = false was present?). So I've added a new setting specifically for extended types to preserve the IDE output.

If we added better ambiguity detection in the future, then we could remove this extra setting and still have nice IDE output in the common case.

@varungandhi-apple
Copy link
Contributor Author

@swift-ci smoke test

@varungandhi-apple
Copy link
Contributor Author

@swift-ci smoke test

The patch introduces a new setting instead of changing existing settings
because the generated interfaces in the IDE have slightly different
requirements; the extended type there is unconditionally not printed
qualified (even if it is ambiguous). This is likely because the
ambiguity heuristic is very weak; it doesn't even do name lookup.
Simplifying that logic would be nice, but then we'd need to update
a bunch of IDE/print* tests and end up with more more visual clutter
in the IDE.

Introducing the new setting means we can change the behavior for
swiftinterface files without affecting the behavior for IDE interfaces.

Fixes rdar://79093752.
varungandhi-apple added a commit to varungandhi-apple/llvm-project that referenced this pull request Jun 12, 2021
@varungandhi-apple
Copy link
Contributor Author

@swiftlang swiftlang deleted a comment from swift-ci Jun 12, 2021
@varungandhi-apple
Copy link
Contributor Author

swiftlang/llvm-project#3040

@swift-ci test macOS

@varungandhi-apple
Copy link
Contributor Author

Got LGTM separately from Slava.

@varungandhi-apple varungandhi-apple merged commit 8f0235e into swiftlang:main Jun 16, 2021
@varungandhi-apple varungandhi-apple deleted the vg-fix-interface-bug branch June 16, 2021 04:10
varungandhi-apple added a commit to varungandhi-apple/llvm-project that referenced this pull request Jun 16, 2021
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