Skip to content

Conversation

@dan-zheng
Copy link
Contributor

Change SourceFile::addTopLevelDecl to update source lookup caches.
If tests pass: make the change robust, respecting access levels.

Change `SourceFile::addTopLevelDecl` to update source lookup caches.
If tests pass: make the change robust, respecting access levels.
@dan-zheng
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented Apr 7, 2020

Build failed
Swift Test OS X Platform
Git Sha - 5565d24

@slavapestov
Copy link
Contributor

We don’t want the list of top level declarations in a source file to change after parsing. Can you instead investigate adding a new kind of FileUnit that stores synthesized declarations instead? Also ideally it should be possible to get all such declarations in “one shot”. We want to avoid mutating the AST where possible.

@dan-zheng
Copy link
Contributor Author

Can you instead investigate adding a new kind of FileUnit that stores synthesized declarations instead?

That sounds good, thank you! I can investigate re-adding a simplest possible DerivedFileUnit.


Also ideally it should be possible to get all such declarations in “one shot”. We want to avoid mutating the AST where possible.

I wonder what "getting all declarations in one shot" would look like, in terms of API calls?

Something like a DerivedFileUnit(SmallVectorImpl<ValueDecl *> topLevelDecls) constructor instead of incremental DerivedFileUnit::addTopLevelDecl(ValueDecl *decl) function calls?

@slavapestov
Copy link
Contributor

Yeah, basically instead of other parts of the compiler adding declarations in an ad-hoc way, you would have a "pull" model where the declarations are synthesized when needed. I'm not sure how to square this with the fact that the SIL optimizer is currently the one doing that though.

@dan-zheng
Copy link
Contributor Author

dan-zheng commented Apr 7, 2020

Closing in favor of #30863, which adds a SynthesizedFileUnit based on feedback here.

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.

3 participants