mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Subscript default arguments
Fixes <https://bugs.swift.org/browse/SR-6118>.
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user