diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index afe07ec6b86f9..fd38ae3c6d8b7 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -957,14 +957,6 @@ Type AbstractFunctionDecl::getThrownInterfaceType() const { llvm::Optional AbstractFunctionDecl::getEffectiveThrownErrorType() const { - // FIXME: Only getters can have thrown error types right now, and DidSet - // has a cyclic reference if we try to get its interface type here. Find a - // better way to express this. - if (auto accessor = dyn_cast(this)) { - if (accessor->getAccessorKind() != AccessorKind::Get) - return llvm::None; - } - Type interfaceType = getInterfaceType(); if (hasImplicitSelfDecl()) { if (auto fnType = interfaceType->getAs()) diff --git a/lib/Sema/TypeCheckAvailability.cpp b/lib/Sema/TypeCheckAvailability.cpp index 40268bfbc76c8..e7f8c68a38aaf 100644 --- a/lib/Sema/TypeCheckAvailability.cpp +++ b/lib/Sema/TypeCheckAvailability.cpp @@ -1199,7 +1199,7 @@ void TypeChecker::buildTypeRefinementContextHierarchyDelayed(SourceFile &SF, Abs if(!RootTRC) return; - if (AFD->getBodyKind() != AbstractFunctionDecl::BodyKind::Unparsed) + if (AFD->getLoc().isInvalid()) return; // Parse the function body. diff --git a/lib/Sema/TypeCheckStorage.cpp b/lib/Sema/TypeCheckStorage.cpp index 3deddf2eb4533..4f6a524ae66fb 100644 --- a/lib/Sema/TypeCheckStorage.cpp +++ b/lib/Sema/TypeCheckStorage.cpp @@ -3797,6 +3797,9 @@ bool SimpleDidSetRequest::evaluate(Evaluator &evaluator, virtual PreWalkResult walkToExprPre(Expr *E) override { if (!E) return Action::Continue(E); + + // If we have an already-resolved reference to the parameter in question, + // we're done. if (auto DRE = dyn_cast(E)) { if (auto decl = DRE->getDecl()) { if (decl == OldValueParam) { @@ -3806,6 +3809,20 @@ bool SimpleDidSetRequest::evaluate(Evaluator &evaluator, } } + // If we have an unresolved reference with the same name as the parameter, + // perform name lookup to determine whether it refers to this parameter. + if (auto UDRE = dyn_cast(E)) { + auto loc = UDRE->getLoc(); + auto sf = OldValueParam->getDeclContext() + ->getOutermostParentSourceFile(); + auto name = UDRE->getName().getFullName(); + if (name == OldValueParam->getName() && + ASTScope::lookupSingleLocalDecl(sf, name, loc) == OldValueParam) { + foundOldValueRef = true; + return Action::Stop(); + } + } + return Action::Continue(E); } @@ -3838,7 +3855,7 @@ bool SimpleDidSetRequest::evaluate(Evaluator &evaluator, // If we find a reference to the implicit 'oldValue' parameter, then it is // not a "simple" didSet because we need to fetch it. auto walker = OldValueFinder(param); - if (auto *body = decl->getTypecheckedBody()) + if (auto *body = decl->getBody()) body->walk(walker); auto hasOldValueRef = walker.didFindOldValueRef(); if (!hasOldValueRef) {