diff --git a/lib/Sema/SyntacticElementTarget.cpp b/lib/Sema/SyntacticElementTarget.cpp index ded817ad96e00..b15f901e02bdb 100644 --- a/lib/Sema/SyntacticElementTarget.cpp +++ b/lib/Sema/SyntacticElementTarget.cpp @@ -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 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(D)); } }; - InvalidationWalker walker; + InvalidationWalker walker(getDeclContext()->getASTContext()); walk(walker); } diff --git a/lib/Sema/TypeCheckConcurrency.cpp b/lib/Sema/TypeCheckConcurrency.cpp index e4fa80b81d166..4b86a801c6c56 100644 --- a/lib/Sema/TypeCheckConcurrency.cpp +++ b/lib/Sema/TypeCheckConcurrency.cpp @@ -2706,7 +2706,7 @@ namespace { PreWalkResult walkToExprPre(Expr *expr) override { // Skip expressions that didn't make it to solution application // because the constraint system diagnosed an error. - if (!expr->getType()) + if (!expr->getType() || expr->getType()->hasError()) return Action::SkipNode(expr); if (auto *openExistential = dyn_cast(expr)) { diff --git a/lib/Sema/TypeCheckEffects.cpp b/lib/Sema/TypeCheckEffects.cpp index 61c324b401a55..89fdcf7f3ef66 100644 --- a/lib/Sema/TypeCheckEffects.cpp +++ b/lib/Sema/TypeCheckEffects.cpp @@ -1283,7 +1283,7 @@ class ApplyClassifier { thrownValue = removeErasureToExistentialError(thrownValue); Type thrownType = thrownValue->getType(); - if (!thrownType) + if (!thrownType || thrownType->hasError()) return Classification::forInvalidCode(); // FIXME: Add a potential effect reason for a throw site. diff --git a/test/SourceKit/CursorInfo/rdar129417672.swift b/test/SourceKit/CursorInfo/rdar129417672.swift new file mode 100644 index 0000000000000..9cc03aba1ccf7 --- /dev/null +++ b/test/SourceKit/CursorInfo/rdar129417672.swift @@ -0,0 +1,19 @@ +// RUN: %sourcekitd-test -req=cursor -pos=12:11 %s -- %s + +private class MacroApplication: SyntaxRewriter { + + override func visitAny(_ node: Syntax) -> Syntax? { + if var declSyntax = node.as(DeclSyntax.self), + let attributedNode = node.asProtocol(WithAttributesSyntax.self), + !attributedNode.attributes.isEmpty + { + for (attribute, spec) in attributesToRemove { + if let index = self.expandedAttributes.firstIndex(where: { expandedAttribute in + expandedAttribute.position == attribute.position + }) { + } else { + } + } + } + } +}