Skip to content

Commit dc21edd

Browse files
committed
Sema: Clean up local property wrapper bookkeeping
1 parent 5abc22e commit dc21edd

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,13 @@ class Solution {
16131613
/// A map from argument expressions to their applied property wrapper expressions.
16141614
llvm::DenseMap<ASTNode, SmallVector<AppliedPropertyWrapper, 2>> appliedPropertyWrappers;
16151615

1616+
ArrayRef<AppliedPropertyWrapper> getAppliedPropertyWrappers(ASTNode anchor) {
1617+
auto found = appliedPropertyWrappers.find(anchor);
1618+
if (found != appliedPropertyWrappers.end())
1619+
return found->second;
1620+
return ArrayRef<AppliedPropertyWrapper>();
1621+
}
1622+
16161623
/// A mapping from the constraint locators for references to various
16171624
/// names (e.g., member references, normal name references, possible
16181625
/// constructions) to the argument lists for the call to that locator.

lib/Sema/CSApply.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,8 +1189,8 @@ namespace {
11891189
calleeFnTy = calleeFnTy->getResult()->castTo<FunctionType>();
11901190
}
11911191

1192-
const auto &appliedPropertyWrappers =
1193-
solution.appliedPropertyWrappers[locator.getAnchor()];
1192+
auto appliedPropertyWrappers =
1193+
solution.getAppliedPropertyWrappers(locator.getAnchor());
11941194
const auto calleeDeclRef = resolveConcreteDeclRef(
11951195
dyn_cast<AbstractFunctionDecl>(declOrClosure), locator);
11961196

@@ -2332,8 +2332,8 @@ namespace {
23322332
->castTo<FunctionType>();
23332333
auto fullSubscriptTy = openedFullFnType->getResult()
23342334
->castTo<FunctionType>();
2335-
auto &appliedWrappers =
2336-
solution.appliedPropertyWrappers[memberLoc->getAnchor()];
2335+
auto appliedWrappers =
2336+
solution.getAppliedPropertyWrappers(memberLoc->getAnchor());
23372337
args = coerceCallArguments(
23382338
args, fullSubscriptTy, subscriptRef, nullptr,
23392339
locator.withPathElement(ConstraintLocator::ApplyArgument),
@@ -6328,6 +6328,7 @@ ArgumentList *ExprRewriter::coerceCallArguments(
63286328
auto *paramDecl = getParameterAt(callee, paramIdx);
63296329
assert(paramDecl);
63306330

6331+
ASSERT(appliedWrapperIndex < appliedPropertyWrappers.size());
63316332
auto appliedWrapper = appliedPropertyWrappers[appliedWrapperIndex++];
63326333
auto wrapperType = solution.simplifyType(appliedWrapper.wrapperType);
63336334
auto initKind = appliedWrapper.initKind;
@@ -8230,7 +8231,8 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,
82308231
// Resolve into a DynamicTypeExpr.
82318232
auto args = apply->getArgs();
82328233

8233-
auto &appliedWrappers = solution.appliedPropertyWrappers[calleeLocator.getAnchor()];
8234+
auto appliedWrappers = solution.getAppliedPropertyWrappers(
8235+
calleeLocator.getAnchor());
82348236
auto fnType = cs.getType(fn)->getAs<FunctionType>();
82358237
args = coerceCallArguments(
82368238
args, fnType, declRef, apply,
@@ -8426,7 +8428,9 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,
84268428
// For function application, convert the argument to the input type of
84278429
// the function.
84288430
if (auto fnType = cs.getType(fn)->getAs<FunctionType>()) {
8429-
auto &appliedWrappers = solution.appliedPropertyWrappers[calleeLocator.getAnchor()];
8431+
auto appliedWrappers = solution.getAppliedPropertyWrappers(
8432+
calleeLocator.getAnchor());
8433+
84308434
args = coerceCallArguments(
84318435
args, fnType, callee, apply,
84328436
locator.withPathElement(ConstraintLocator::ApplyArgument),

0 commit comments

Comments
 (0)