@@ -1468,6 +1468,7 @@ namespace {
1468
1468
enum class OpenedExistentialAdjustmentFlags {
1469
1469
/// The argument should be made inout after opening.
1470
1470
InOut = 0x01,
1471
+ LValue = 0x02,
1471
1472
};
1472
1473
1473
1474
using OpenedExistentialAdjustments =
@@ -1541,16 +1542,18 @@ shouldOpenExistentialCallArgument(
1541
1542
1542
1543
OpenedExistentialAdjustments adjustments;
1543
1544
1545
+ // The argument may be a "var" instead of a "let".
1546
+ if (auto lv = argTy->getAs<LValueType>()) {
1547
+ argTy = lv->getObjectType();
1548
+ adjustments |= OpenedExistentialAdjustmentFlags::LValue;
1549
+ }
1550
+
1544
1551
// If the argument is inout, strip it off and we can add it back.
1545
1552
if (auto inOutArg = argTy->getAs<InOutType>()) {
1546
1553
argTy = inOutArg->getObjectType();
1547
1554
adjustments |= OpenedExistentialAdjustmentFlags::InOut;
1548
1555
}
1549
1556
1550
- // The argument may be a "var" instead of a "let".
1551
- if (auto lv = dyn_cast<LValueType>(argTy->getCanonicalType()))
1552
- argTy = lv->getObjectType();
1553
-
1554
1557
// The argument type needs to be an existential type or metatype thereof.
1555
1558
if (!argTy->isAnyExistentialType())
1556
1559
return None;
@@ -1950,6 +1953,9 @@ static ConstraintSystem::TypeMatchResult matchCallArguments(
1950
1953
std::tie(argTy, opened) = cs.openExistentialType(
1951
1954
existentialType, cs.getConstraintLocator(loc));
1952
1955
1956
+ if (adjustments.contains(OpenedExistentialAdjustmentFlags::LValue))
1957
+ argTy = LValueType::get(argTy);
1958
+
1953
1959
if (adjustments.contains(OpenedExistentialAdjustmentFlags::InOut))
1954
1960
argTy = InOutType::get(argTy);
1955
1961
0 commit comments