@@ -903,11 +903,6 @@ namespace {
903
903
bool baseIsInstance) {
904
904
ValueDecl *member = choice.getDecl ();
905
905
906
- // FIXME: We should finish plumbing this through for dynamic
907
- // lookup as well.
908
- if (choice.getKind () == OverloadChoiceKind::DeclViaDynamic)
909
- return false ;
910
-
911
906
// If we're inside a selector expression, don't build the thunk.
912
907
// Were not actually going to emit the member reference, just
913
908
// look at the AST.
@@ -921,9 +916,11 @@ namespace {
921
916
if (!baseIsInstance && member->isInstanceMember ())
922
917
return true ;
923
918
924
- // Bound optional method references are represented via
925
- // DynamicMemberRefExpr instead of a curry thunk.
926
- if (member->getAttrs ().hasAttribute <OptionalAttr>())
919
+ // Bound member references that are '@objc optional' or found via dynamic
920
+ // lookup are always represented via DynamicMemberRefExpr instead of a
921
+ // curry thunk.
922
+ if (member->getAttrs ().hasAttribute <OptionalAttr>() ||
923
+ choice.getKind () == OverloadChoiceKind::DeclViaDynamic)
927
924
return false ;
928
925
929
926
// Figure out how many argument lists we need.
@@ -1590,8 +1587,8 @@ namespace {
1590
1587
}
1591
1588
1592
1589
// Handle dynamic references.
1593
- if (isDynamic || ( !needsCurryThunk &&
1594
- member->getAttrs ().hasAttribute <OptionalAttr>())) {
1590
+ if (!needsCurryThunk &&
1591
+ (isDynamic || member->getAttrs ().hasAttribute <OptionalAttr>())) {
1595
1592
base = cs.coerceToRValue (base);
1596
1593
Expr *ref = new (context) DynamicMemberRefExpr (base, dotLoc, memberRef,
1597
1594
memberLoc);
0 commit comments