Sema: Subscript default arguments

Fixes <https://bugs.swift.org/browse/SR-6118>.
This commit is contained in:
Slava Pestov
2019-04-02 01:37:56 -04:00
parent 043d76a3bf
commit 6bb36b5c01
19 changed files with 308 additions and 44 deletions

View File

@@ -127,7 +127,7 @@ bool constraints::areConservativelyCompatibleArgumentLabels(
// we can get an unapplied declaration reference back.
bool hasCurriedSelf;
if (isa<SubscriptDecl>(decl)) {
hasCurriedSelf = false;
hasCurriedSelf = true;
} else if (!baseType || baseType->is<ModuleType>()) {
hasCurriedSelf = false;
} else if (baseType->is<AnyMetatypeType>() && decl->isInstanceMember()) {
@@ -146,7 +146,6 @@ bool constraints::areConservativelyCompatibleArgumentLabels(
if (auto fn = dyn_cast<AbstractFunctionDecl>(decl)) {
fTy = fn->getInterfaceType()->castTo<AnyFunctionType>();
} else if (auto subscript = dyn_cast<SubscriptDecl>(decl)) {
assert(!hasCurriedSelf && "Subscripts never have curried 'self'");
fTy = subscript->getInterfaceType()->castTo<AnyFunctionType>();
} else if (auto enumElement = dyn_cast<EnumElementDecl>(decl)) {
fTy = enumElement->getInterfaceType()->castTo<AnyFunctionType>();
@@ -160,7 +159,7 @@ bool constraints::areConservativelyCompatibleArgumentLabels(
}
const AnyFunctionType *levelTy = fTy;
if (hasCurriedSelf) {
if (hasCurriedSelf && !isa<SubscriptDecl>(decl)) {
levelTy = levelTy->getResult()->getAs<AnyFunctionType>();
assert(levelTy && "Parameter list curry level does not match type");
}