-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fixes for expression type checking with parse-time name lookup disabled #34088
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 6 commits into
swiftlang:main
from
slavapestov:constraint-solver-fixes-for-astscope
Sep 26, 2020
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
29ce772
AST: Convert ConstructorDecl::getDelegatingOrChainedInitKind() into a…
slavapestov 6b98f8f
ASTScope: Add a new lookupSingleLocalDecl() entry point
slavapestov dcafd58
Sema: Use ASTScope::lookupSingleLocalDecl() in MissingOptionalUnwrapF…
slavapestov 8ec878b
Sema: Use ASTScope::lookupSingleLocalDecl() in CSGen's CollectVarRefs…
slavapestov ddc0cbd
Sema: Use ASTScope::lookupSingleLocalDecl() in BodyInitKindRequest
slavapestov 6a82f24
Sema: Don't trigger ImplInfoRequest from TypeChecker::buildRefExpr()
slavapestov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -451,14 +451,7 @@ class alignas(1 << DeclAlignInBits) Decl { | |
/// Whether we have computed the above. | ||
IsTransparentComputed : 1); | ||
|
||
SWIFT_INLINE_BITFIELD(ConstructorDecl, AbstractFunctionDecl, 3+1+1, | ||
/// The body initialization kind (+1), or zero if not yet computed. | ||
/// | ||
/// This value is cached but is not serialized, because it is a property | ||
/// of the definition of the constructor that is useful only to semantic | ||
/// analysis and SIL generation. | ||
ComputedBodyInitKind : 3, | ||
|
||
SWIFT_INLINE_BITFIELD(ConstructorDecl, AbstractFunctionDecl, 1+1, | ||
/// Whether this constructor can fail, by building an Optional type. | ||
Failable : 1, | ||
|
||
|
@@ -6770,6 +6763,37 @@ enum class CtorInitializerKind { | |
Factory | ||
}; | ||
|
||
/// Specifies the kind of initialization call performed within the body | ||
/// of the constructor, e.g., self.init or super.init. | ||
enum class BodyInitKind { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, good choice to use the |
||
/// There are no calls to self.init or super.init. | ||
None, | ||
/// There is a call to self.init, which delegates to another (peer) | ||
/// initializer. | ||
Delegating, | ||
/// There is a call to super.init, which chains to a superclass initializer. | ||
Chained, | ||
/// There are no calls to self.init or super.init explicitly in the body of | ||
/// the constructor, but a 'super.init' call will be implicitly added | ||
/// by semantic analysis. | ||
ImplicitChained | ||
}; | ||
|
||
struct BodyInitKindAndExpr { | ||
BodyInitKind initKind; | ||
ApplyExpr *initExpr; | ||
|
||
BodyInitKindAndExpr() : initKind(BodyInitKind::None), initExpr(nullptr) {} | ||
|
||
BodyInitKindAndExpr(BodyInitKind initKind, ApplyExpr *initExpr) | ||
: initKind(initKind), initExpr(initExpr) {} | ||
|
||
friend bool operator==(BodyInitKindAndExpr lhs, BodyInitKindAndExpr rhs) { | ||
return (lhs.initKind == rhs.initKind && | ||
lhs.initExpr == rhs.initExpr); | ||
} | ||
}; | ||
|
||
/// ConstructorDecl - Declares a constructor for a type. For example: | ||
/// | ||
/// \code | ||
|
@@ -6818,38 +6842,11 @@ class ConstructorDecl : public AbstractFunctionDecl { | |
|
||
ParamDecl **getImplicitSelfDeclStorage() { return &SelfDecl; } | ||
|
||
/// Specifies the kind of initialization call performed within the body | ||
/// of the constructor, e.g., self.init or super.init. | ||
enum class BodyInitKind { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, saw the insertion of this before the deletion. Didn't realize it wasn't a pure addition. |
||
/// There are no calls to self.init or super.init. | ||
None, | ||
/// There is a call to self.init, which delegates to another (peer) | ||
/// initializer. | ||
Delegating, | ||
/// There is a call to super.init, which chains to a superclass initializer. | ||
Chained, | ||
/// There are no calls to self.init or super.init explicitly in the body of | ||
/// the constructor, but a 'super.init' call will be implicitly added | ||
/// by semantic analysis. | ||
ImplicitChained | ||
}; | ||
|
||
/// Determine whether the body of this constructor contains any delegating | ||
/// or superclass initializations (\c self.init or \c super.init, | ||
/// respectively) within its body. | ||
/// | ||
/// \param diags If non-null, this check will ensure that the constructor | ||
/// body is consistent in its use of delegation vs. chaining and emit any | ||
/// diagnostics through the given diagnostic engine. | ||
/// | ||
/// \param init If non-null and there is an explicit \c self.init or | ||
/// \c super.init within the body, will be set to point at that | ||
/// initializer. | ||
BodyInitKind getDelegatingOrChainedInitKind(DiagnosticEngine *diags, | ||
ApplyExpr **init = nullptr) const; | ||
void clearCachedDelegatingOrChainedInitKind() { | ||
Bits.ConstructorDecl.ComputedBodyInitKind = 0; | ||
} | ||
BodyInitKindAndExpr getDelegatingOrChainedInitKind() const; | ||
void clearCachedDelegatingOrChainedInitKind(); | ||
|
||
/// Whether this constructor is required. | ||
bool isRequired() const { | ||
|
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
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
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
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
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
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
Oops, something went wrong.
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.
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.
Totally optional thought: It could nice to add a sentence like: "Needed to ... when ..."