Skip to content

Commit 24a5003

Browse files
committed
[ConstraintSystem] Materialize locator only once per missing argument
Instead of materializing locator twice from the same builder per missing argument, do it only once and use result to create argument type variable and its "defaults to Any" constraint.
1 parent 0967783 commit 24a5003

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -837,20 +837,20 @@ class ArgumentFailureTracker : public MatchCallArgumentListener {
837837
const auto &param = Parameters[paramIdx];
838838

839839
unsigned newArgIdx = Arguments.size();
840-
auto argLoc =
840+
auto *argLoc = CS.getConstraintLocator(
841841
Locator
842842
.withPathElement(LocatorPathElt::ApplyArgToParam(
843843
newArgIdx, paramIdx, param.getParameterFlags()))
844-
.withPathElement(LocatorPathElt::SynthesizedArgument(newArgIdx));
844+
.withPathElement(LocatorPathElt::SynthesizedArgument(newArgIdx)));
845845

846-
auto *argType = CS.createTypeVariable(
847-
CS.getConstraintLocator(argLoc),
848-
TVO_CanBindToInOut | TVO_CanBindToLValue | TVO_CanBindToNoEscape);
846+
auto *argType =
847+
CS.createTypeVariable(argLoc, TVO_CanBindToInOut | TVO_CanBindToLValue |
848+
TVO_CanBindToNoEscape);
849849

850850
CS.recordHole(argType);
851-
CS.addUnsolvedConstraint(Constraint::create(
852-
CS, ConstraintKind::Defaultable, argType, CS.getASTContext().TheAnyType,
853-
CS.getConstraintLocator(argLoc)));
851+
CS.addUnsolvedConstraint(
852+
Constraint::create(CS, ConstraintKind::Defaultable, argType,
853+
CS.getASTContext().TheAnyType, argLoc));
854854

855855
Arguments.push_back(param.withType(argType));
856856
++NumSynthesizedArgs;

0 commit comments

Comments
 (0)