Skip to content

Commit 306e9a3

Browse files
authored
Merge pull request #9085 from slavapestov/subclass-existential-executable-tests
Subclass existential executable tests
2 parents 1478159 + 77b760d commit 306e9a3

File tree

4 files changed

+548
-6
lines changed

4 files changed

+548
-6
lines changed

lib/Sema/CSApply.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -897,18 +897,19 @@ namespace {
897897

898898
// If the base is already an lvalue with the right base type, we can
899899
// pass it as an inout qualified type.
900-
auto selfParamTy = selfTy;
900+
auto selfParamTy = isDynamic ? selfTy : containerTy;
901901

902902
if (selfTy->isEqual(baseTy))
903903
if (cs.getType(base)->is<LValueType>())
904904
selfParamTy = InOutType::get(selfTy);
905+
905906
base = coerceObjectArgumentToType(
906907
base, selfParamTy, member, semantics,
907908
locator.withPathElement(ConstraintLocator::MemberRefBase));
908909
} else {
909910
// Convert the base to an rvalue of the appropriate metatype.
910911
base = coerceToType(base,
911-
MetatypeType::get(selfTy),
912+
MetatypeType::get(isDynamic ? selfTy : containerTy),
912913
locator.withPathElement(
913914
ConstraintLocator::MemberRefBase));
914915
if (!base)
@@ -1347,8 +1348,6 @@ namespace {
13471348
}
13481349

13491350
// Figure out the index and result types.
1350-
auto containerTy
1351-
= subscript->getDeclContext()->getDeclaredTypeOfContext();
13521351
auto subscriptTy = simplifyType(selected->openedType);
13531352
auto indexTy = subscriptTy->castTo<AnyFunctionType>()->getInput();
13541353
auto resultTy = subscriptTy->castTo<AnyFunctionType>()->getResult();
@@ -1362,7 +1361,6 @@ namespace {
13621361
if (knownOpened != solution.OpenedExistentialTypes.end()) {
13631362
base = openExistentialReference(base, knownOpened->second, subscript);
13641363
baseTy = knownOpened->second;
1365-
containerTy = baseTy;
13661364
}
13671365

13681366
// Coerce the index argument.
@@ -1407,7 +1405,7 @@ namespace {
14071405
// Convert the base.
14081406
auto openedFullFnType = selected->openedFullType->castTo<FunctionType>();
14091407
auto openedBaseType = openedFullFnType->getInput();
1410-
containerTy = solution.simplifyType(openedBaseType);
1408+
auto containerTy = solution.simplifyType(openedBaseType);
14111409
base = coerceObjectArgumentToType(
14121410
base, containerTy, subscript, AccessSemantics::Ordinary,
14131411
locator.withPathElement(ConstraintLocator::MemberRefBase));

0 commit comments

Comments
 (0)