@@ -5496,21 +5496,6 @@ bool ConstraintSystem::diagnoseAmbiguityWithFixes(
5496
5496
// Aggregate all requirement fixes that belong to the same callee
5497
5497
// and attempt to diagnose possible ambiguities.
5498
5498
{
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
-
5514
5499
// Aggregates fixes fixes attached to `buildExpression` and `buildBlock`
5515
5500
// methods at the particular source location.
5516
5501
llvm::MapVector<SourceLoc, SmallVector<FixInContext, 4 >>
@@ -5526,7 +5511,8 @@ bool ConstraintSystem::diagnoseAmbiguityWithFixes(
5526
5511
5527
5512
auto *calleeLoc = entry.first ->getCalleeLocator (fix->getLocator ());
5528
5513
5529
- if (isResultBuilderMethodRef (calleeLoc->getAnchor ())) {
5514
+ auto *UDE = getAsExpr<UnresolvedDotExpr>(calleeLoc->getAnchor ());
5515
+ if (UDE && isResultBuilderMethodReference (getASTContext (), UDE)) {
5530
5516
auto *anchor = castToExpr<Expr>(calleeLoc->getAnchor ());
5531
5517
builderMethodRequirementFixes[anchor->getLoc ()].push_back (entry);
5532
5518
} else {
@@ -7971,3 +7957,17 @@ void constraints::dumpAnchor(ASTNode anchor, SourceManager *SM,
7971
7957
}
7972
7958
// TODO(diagnostics): Implement the rest of the cases.
7973
7959
}
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