@@ -5496,21 +5496,6 @@ bool ConstraintSystem::diagnoseAmbiguityWithFixes(
54965496 // Aggregate all requirement fixes that belong to the same callee
54975497 // and attempt to diagnose possible ambiguities.
54985498 {
5499- auto isResultBuilderMethodRef = [&](ASTNode node) {
5500- auto *UDE = getAsExpr<UnresolvedDotExpr>(node);
5501- if (!(UDE && UDE->isImplicit ()))
5502- return false ;
5503-
5504- auto &ctx = getASTContext ();
5505- SmallVector<Identifier, 4 > builderMethods (
5506- {ctx.Id_buildBlock , ctx.Id_buildExpression , ctx.Id_buildPartialBlock ,
5507- ctx.Id_buildFinalResult });
5508-
5509- return llvm::any_of (builderMethods, [&](const Identifier &methodId) {
5510- return UDE->getName ().compare (DeclNameRef (methodId)) == 0 ;
5511- });
5512- };
5513-
55145499 // Aggregates fixes fixes attached to `buildExpression` and `buildBlock`
55155500 // methods at the particular source location.
55165501 llvm::MapVector<SourceLoc, SmallVector<FixInContext, 4 >>
@@ -5526,7 +5511,8 @@ bool ConstraintSystem::diagnoseAmbiguityWithFixes(
55265511
55275512 auto *calleeLoc = entry.first ->getCalleeLocator (fix->getLocator ());
55285513
5529- if (isResultBuilderMethodRef (calleeLoc->getAnchor ())) {
5514+ auto *UDE = getAsExpr<UnresolvedDotExpr>(calleeLoc->getAnchor ());
5515+ if (UDE && isResultBuilderMethodReference (getASTContext (), UDE)) {
55305516 auto *anchor = castToExpr<Expr>(calleeLoc->getAnchor ());
55315517 builderMethodRequirementFixes[anchor->getLoc ()].push_back (entry);
55325518 } else {
@@ -7971,3 +7957,17 @@ void constraints::dumpAnchor(ASTNode anchor, SourceManager *SM,
79717957 }
79727958 // TODO(diagnostics): Implement the rest of the cases.
79737959}
7960+
7961+ bool constraints::isResultBuilderMethodReference (ASTContext &ctx,
7962+ UnresolvedDotExpr *UDE) {
7963+ if (!(UDE && UDE->isImplicit ()))
7964+ return false ;
7965+
7966+ SmallVector<Identifier, 4 > builderMethods (
7967+ {ctx.Id_buildBlock , ctx.Id_buildExpression , ctx.Id_buildPartialBlock ,
7968+ ctx.Id_buildFinalResult });
7969+
7970+ return llvm::any_of (builderMethods, [&](const Identifier &methodId) {
7971+ return UDE->getName ().compare (DeclNameRef (methodId)) == 0 ;
7972+ });
7973+ }
0 commit comments