@@ -897,18 +897,19 @@ namespace {
897
897
898
898
// If the base is already an lvalue with the right base type, we can
899
899
// pass it as an inout qualified type.
900
- auto selfParamTy = selfTy;
900
+ auto selfParamTy = isDynamic ? selfTy : containerTy ;
901
901
902
902
if (selfTy->isEqual (baseTy))
903
903
if (cs.getType (base)->is <LValueType>())
904
904
selfParamTy = InOutType::get (selfTy);
905
+
905
906
base = coerceObjectArgumentToType (
906
907
base, selfParamTy, member, semantics,
907
908
locator.withPathElement (ConstraintLocator::MemberRefBase));
908
909
} else {
909
910
// Convert the base to an rvalue of the appropriate metatype.
910
911
base = coerceToType (base,
911
- MetatypeType::get (selfTy),
912
+ MetatypeType::get (isDynamic ? selfTy : containerTy ),
912
913
locator.withPathElement (
913
914
ConstraintLocator::MemberRefBase));
914
915
if (!base)
@@ -1347,8 +1348,6 @@ namespace {
1347
1348
}
1348
1349
1349
1350
// Figure out the index and result types.
1350
- auto containerTy
1351
- = subscript->getDeclContext ()->getDeclaredTypeOfContext ();
1352
1351
auto subscriptTy = simplifyType (selected->openedType );
1353
1352
auto indexTy = subscriptTy->castTo <AnyFunctionType>()->getInput ();
1354
1353
auto resultTy = subscriptTy->castTo <AnyFunctionType>()->getResult ();
@@ -1362,7 +1361,6 @@ namespace {
1362
1361
if (knownOpened != solution.OpenedExistentialTypes .end ()) {
1363
1362
base = openExistentialReference (base, knownOpened->second , subscript);
1364
1363
baseTy = knownOpened->second ;
1365
- containerTy = baseTy;
1366
1364
}
1367
1365
1368
1366
// Coerce the index argument.
@@ -1407,7 +1405,7 @@ namespace {
1407
1405
// Convert the base.
1408
1406
auto openedFullFnType = selected->openedFullType ->castTo <FunctionType>();
1409
1407
auto openedBaseType = openedFullFnType->getInput ();
1410
- containerTy = solution.simplifyType (openedBaseType);
1408
+ auto containerTy = solution.simplifyType (openedBaseType);
1411
1409
base = coerceObjectArgumentToType (
1412
1410
base, containerTy, subscript, AccessSemantics::Ordinary,
1413
1411
locator.withPathElement (ConstraintLocator::MemberRefBase));
0 commit comments