@@ -2687,6 +2687,21 @@ namespace {
26872687 varType = TypeChecker::getOptionalType (var->getLoc (), varType);
26882688 }
26892689
2690+ auto makeTypeLocatableIfPossible = [&var](Type type) -> Type {
2691+ if (auto loc = var->getLoc ()) {
2692+ return LocatableType::get (loc, type);
2693+ }
2694+ return type;
2695+ };
2696+
2697+ auto useLocatableTypes = [&]() -> bool {
2698+ if (!CS.inSalvageMode ())
2699+ return false ;
2700+
2701+ return var->isImplicit () &&
2702+ var->getNameStr ().starts_with (" $__builder" );
2703+ };
2704+
26902705 // When we are supposed to bind pattern variables, create a fresh
26912706 // type variable and a one-way constraint to assign it to either the
26922707 // deduced type or the externally-imposed type.
@@ -2711,6 +2726,9 @@ namespace {
27112726
27122727 CS.addConstraint (ConstraintKind::OneWayEqual, oneWayVarType,
27132728 varType, locator);
2729+
2730+ if (useLocatableTypes ())
2731+ oneWayVarType = makeTypeLocatableIfPossible (oneWayVarType);
27142732 }
27152733
27162734 // Ascribe a type to the declaration so it's always available to
@@ -2772,6 +2790,9 @@ namespace {
27722790 CS.getConstraintLocator (locator));
27732791 }
27742792
2793+ if (useLocatableTypes ())
2794+ declTy = makeTypeLocatableIfPossible (declTy);
2795+
27752796 CS.setType (var, declTy);
27762797 }
27772798
0 commit comments