Skip to content

Subclass existential executable tests #9085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions lib/Sema/CSApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -897,18 +897,19 @@ namespace {

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

if (selfTy->isEqual(baseTy))
if (cs.getType(base)->is<LValueType>())
selfParamTy = InOutType::get(selfTy);

base = coerceObjectArgumentToType(
base, selfParamTy, member, semantics,
locator.withPathElement(ConstraintLocator::MemberRefBase));
} else {
// Convert the base to an rvalue of the appropriate metatype.
base = coerceToType(base,
MetatypeType::get(selfTy),
MetatypeType::get(isDynamic ? selfTy : containerTy),
locator.withPathElement(
ConstraintLocator::MemberRefBase));
if (!base)
Expand Down Expand Up @@ -1347,8 +1348,6 @@ namespace {
}

// Figure out the index and result types.
auto containerTy
= subscript->getDeclContext()->getDeclaredTypeOfContext();
auto subscriptTy = simplifyType(selected->openedType);
auto indexTy = subscriptTy->castTo<AnyFunctionType>()->getInput();
auto resultTy = subscriptTy->castTo<AnyFunctionType>()->getResult();
Expand All @@ -1362,7 +1361,6 @@ namespace {
if (knownOpened != solution.OpenedExistentialTypes.end()) {
base = openExistentialReference(base, knownOpened->second, subscript);
baseTy = knownOpened->second;
containerTy = baseTy;
}

// Coerce the index argument.
Expand Down Expand Up @@ -1407,7 +1405,7 @@ namespace {
// Convert the base.
auto openedFullFnType = selected->openedFullType->castTo<FunctionType>();
auto openedBaseType = openedFullFnType->getInput();
containerTy = solution.simplifyType(openedBaseType);
auto containerTy = solution.simplifyType(openedBaseType);
base = coerceObjectArgumentToType(
base, containerTy, subscript, AccessSemantics::Ordinary,
locator.withPathElement(ConstraintLocator::MemberRefBase));
Expand Down
Loading