-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Build type checked bodies for more synthesized declarations #24665
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
slavapestov
merged 4 commits into
swiftlang:master
from
slavapestov:fully-checked-trivial-accessors
May 14, 2019
Merged
Build type checked bodies for more synthesized declarations #24665
slavapestov
merged 4 commits into
swiftlang:master
from
slavapestov:fully-checked-trivial-accessors
May 14, 2019
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51d0778
to
3cf8c2a
Compare
@swift-ci Please test |
@swift-ci Please test source compatibility |
@swift-ci Please test compiler performance |
xymus
approved these changes
May 10, 2019
…ng of invalid code
When applying a solution to a nil literal of Optional type, we would build a direct reference to Optional<T>.none instead of leaving the NilLiteralExpr in place, because this would generate more efficient SIL that avoided the call to the Optional(nilLiteral: ()) witness. However, a few places in the type checker build type-checked AST, and they build NilLiteralExpr directly. Moving the peephole to SILGen's lowering of NilLiteralExpr allows us to simplify generated SIL even further by eliding an unnecessary metatype value. Furthermore, it allows SILGen to accept NilLiteralExprs that do not have a ConcreteDeclRef set, which makes type-checked AST easier to build.
This includes all synthesized accessors except for lazy getters and observer setters. Building checked AST has certain advantages: - It is faster, avoiding the need to create and solve ConstraintSystems or performing various diagnostic and semantic walks over the AST. - It allows us to postpone delayed body synthesis until needed in SILGen, instead of having to walk a list of "external declarations" in Sema. It also unblocks lazier conformance checking. Now that SILGen can trigger conformance checking on its own, we need to be able to synthesize bodies of accessors that witness protocol requirements. This will allow us to eventually remove Sema's "used conformances" list. Note that for now, various utility functions in CodeSynthesis.cpp are used for both checked and unchecked function bodies, so they take a 'typeChecked' boolean parameter that complicates some logic more than necessary. Once the remaining body synthesizers are refactored to build type-checked AST, the 'typeChecked' flag will go away.
Similarly to trivial accessors, the body of a synthesized designated initializer override is simple enough that we can build it directly without involving the constraint solver.
3cf8c2a
to
a18c32a
Compare
@swift-ci Please test source compatibility |
@swift-ci Please smoke test |
This was referenced May 15, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Building checked AST has certain advantages:
It is faster, avoiding the need to create and solve ConstraintSystems
or performing various diagnostic and semantic walks over the AST.
It allows us to postpone delayed body synthesis until needed in SILGen,
instead of having to walk a list of "external declarations" in Sema.
It also unblocks lazier conformance checking. Now that SILGen can
trigger conformance checking on its own, we need to be able to
synthesize bodies of accessors that witness protocol requirements.
This will allow us to eventually remove Sema's "used conformances"
list.
Note that for now, various utility functions in CodeSynthesis.cpp are
used for both checked and unchecked function bodies, so they take a
'typeChecked' boolean parameter that complicates some logic more than
necessary. Once the remaining body synthesizers are refactored to
build type-checked AST, the 'typeChecked' flag will go away.