mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CS] Fill in ErrorTypes for expressions that fail to type-check
Ensure we always produce typed AST, even if we fail to apply a solution. This fixes a cursor info issue where we'd to type-check a closure twice due to it not having a type set. rdar://129417672
This commit is contained in:
@@ -303,9 +303,15 @@ bool SyntacticElementTarget::contextualTypeIsOnlyAHint() const {
|
||||
|
||||
void SyntacticElementTarget::markInvalid() const {
|
||||
class InvalidationWalker : public ASTWalker {
|
||||
ASTContext &Ctx;
|
||||
|
||||
public:
|
||||
InvalidationWalker(ASTContext &ctx) : Ctx(ctx) {}
|
||||
|
||||
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
|
||||
// TODO: We ought to fill in ErrorTypes for expressions here; ultimately
|
||||
// type-checking should always produce typed AST.
|
||||
if (!E->getType())
|
||||
E->setType(ErrorType::get(Ctx));
|
||||
|
||||
return Action::Continue(E);
|
||||
}
|
||||
|
||||
@@ -321,7 +327,7 @@ void SyntacticElementTarget::markInvalid() const {
|
||||
return Action::VisitNodeIf(isa<PatternBindingDecl>(D));
|
||||
}
|
||||
};
|
||||
InvalidationWalker walker;
|
||||
InvalidationWalker walker(getDeclContext()->getASTContext());
|
||||
walk(walker);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user