Skip to content

Requestify implicit imports #31016

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

hamishknight
Copy link
Contributor

@hamishknight hamishknight commented Apr 14, 2020

Add ModuleImplicitImportsRequest, which computes the modules that should be implicitly imported by each file of a given module by consulting the ImplicitImportInfo that it's created with. Use this request in import resolution to add all the necessary implicit imports.

Along with swiftlang/llvm-project#1079, this allows us to remove SourceFile::addImports, ensuring that a file's imports are computed only once.

Note I'm not planning on merging this until after the 5.3 re-branch.

@hamishknight
Copy link
Contributor Author

swiftlang/llvm-project#1079

@swift-ci please test

@hamishknight
Copy link
Contributor Author

@swift-ci please test source compatibility Debug

@hamishknight hamishknight requested review from CodaFi and beccadax April 15, 2020 01:16
@CodaFi
Copy link
Contributor

CodaFi commented Apr 15, 2020

Debug failure seems like a consequence of Slava's patches to opaque type reconstruction. I wouldn't worry about it.

Copy link
Contributor

@CodaFi CodaFi left a comment

Choose a reason for hiding this comment

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

Nice cleanups here.

Check whether the user has provided a valid
identifier when parsing the options. Also make
ImplicitImportModuleNames a private member of
FrontendOptions to prevent mutation after being
parsed.
Add ModuleImplicitImportsRequest, which computes
the modules that should be implicitly imported by
each file of a given module. Use this request in
import resolution to add all the necessary
implicit imports.

The request computes the implicit imports by
consulting the ImplicitImportInfo, which ModuleDecl
can now be created with. This allows us to remove
uses of `SourceFile::addImports` in favor of
adding modules needed to be implicitly imported to
the ImplicitImportInfo.
The associated comment appears to outdated. Make
sure we continue to record implicit imports for
empty files.
Temporarily replace with `SourceFile::setImports`
until import resolution is requestified. Now
imports are only set once for a given SourceFile.

Because we're now asserting in more places that
import resolution must have run before querying
imports, this commit also adds
`getCachedUnderlyingType` to TypeAliasDecl to stop
the ASTDumper from trying to query imports for a
-dump-parse invocation.
@hamishknight hamishknight force-pushed the a-balance-of-payments-deficit branch from 92ef6bc to 92103a7 Compare April 20, 2020 20:20
@hamishknight
Copy link
Contributor Author

Rebased to resolve a merge conflict.

swiftlang/llvm-project#1079

@swift-ci please test

@swiftlang swiftlang deleted a comment from swift-ci Apr 20, 2020
@hamishknight
Copy link
Contributor Author

swiftlang/llvm-project#1079

@swift-ci please test Linux

@hamishknight hamishknight merged commit d929395 into swiftlang:master Apr 20, 2020
@hamishknight hamishknight deleted the a-balance-of-payments-deficit branch April 20, 2020 23:51
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