@@ -1526,8 +1526,7 @@ Type ConstraintSystem::getEffectiveOverloadType(const OverloadChoice &overload,
1526
1526
// See ConstraintSystem::resolveOverload() -- optional and dynamic
1527
1527
// subscripts are a special case, because the optionality is
1528
1528
// applied to the result type and not the type of the reference.
1529
- if (subscript->getAttrs ().hasAttribute <OptionalAttr>() ||
1530
- overload.getKind () == OverloadChoiceKind::DeclViaDynamic)
1529
+ if (subscript->getAttrs ().hasAttribute <OptionalAttr>())
1531
1530
elementTy = OptionalType::get (elementTy->getRValueType ());
1532
1531
1533
1532
auto indices = subscript->getInterfaceType ()
@@ -1559,11 +1558,14 @@ Type ConstraintSystem::getEffectiveOverloadType(const OverloadChoice &overload,
1559
1558
}
1560
1559
1561
1560
type = type->castTo <FunctionType>()->getResult ();
1562
- } else {
1563
- return type;
1564
1561
}
1565
1562
}
1566
1563
1564
+ // Handle "@objc optional" for non-subscripts; subscripts are handled above.
1565
+ if (decl->getAttrs ().hasAttribute <OptionalAttr>() &&
1566
+ !isa<SubscriptDecl>(decl))
1567
+ type = OptionalType::get (type->getRValueType ());
1568
+
1567
1569
return type;
1568
1570
}
1569
1571
@@ -1821,7 +1823,7 @@ Type ConstraintSystem::findCommonOverloadType(
1821
1823
// If we can't even get a type for the overload, there's nothing more to
1822
1824
// do.
1823
1825
Type overloadType =
1824
- getEffectiveOverloadType (overload, /* allowMembers=*/ false , /* FIXME:*/ DC);
1826
+ getEffectiveOverloadType (overload, /* allowMembers=*/ false , /* FIXME:*/ DC);
1825
1827
if (!overloadType) {
1826
1828
return true ;
1827
1829
}
0 commit comments