@@ -6034,10 +6034,29 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
6034
6034
}
6035
6035
}
6036
6036
6037
+ // If we have candidates, and we're doing a member lookup for a pattern
6038
+ // match, unwrap optionals and try again to allow implicit creation of
6039
+ // optional "some" patterns (spelled "?").
6040
+ if (result.ViableCandidates .empty () && result.UnviableCandidates .empty () &&
6041
+ memberLocator &&
6042
+ memberLocator->isLastElement <LocatorPathElt::PatternMatch>() &&
6043
+ instanceTy->getOptionalObjectType () &&
6044
+ baseObjTy->is <AnyMetatypeType>()) {
6045
+ SmallVector<Type, 2 > optionals;
6046
+ Type instanceObjectTy = instanceTy->lookThroughAllOptionalTypes (optionals);
6047
+ Type metaObjectType = MetatypeType::get (instanceObjectTy);
6048
+ auto result = performMemberLookup (
6049
+ constraintKind, memberName, metaObjectType,
6050
+ functionRefKind, memberLocator, includeInaccessibleMembers);
6051
+ result.numImplicitOptionalUnwraps = optionals.size ();
6052
+ result.actualBaseType = metaObjectType;
6053
+ return result;
6054
+ }
6055
+
6037
6056
// If we're looking into a metatype for an unresolved member lookup, look
6038
6057
// through optional types.
6039
6058
//
6040
- // FIXME: The short-circuit here is lame .
6059
+ // FIXME: Unify with the above code path .
6041
6060
if (result.ViableCandidates .empty () &&
6042
6061
baseObjTy->is <AnyMetatypeType>() &&
6043
6062
constraintKind == ConstraintKind::UnresolvedValueMember) {
@@ -6097,25 +6116,6 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
6097
6116
}
6098
6117
}
6099
6118
6100
- // If we have candidates, and we're doing a member lookup for a pattern
6101
- // match, unwrap optionals and try again to allow implicit creation of
6102
- // optional "some" patterns (spelled "?").
6103
- if (result.ViableCandidates .empty () && result.UnviableCandidates .empty () &&
6104
- memberLocator &&
6105
- memberLocator->isLastElement <LocatorPathElt::PatternMatch>() &&
6106
- instanceTy->getOptionalObjectType () &&
6107
- baseObjTy->is <AnyMetatypeType>()) {
6108
- SmallVector<Type, 2 > optionals;
6109
- Type instanceObjectTy = instanceTy->lookThroughAllOptionalTypes (optionals);
6110
- Type metaObjectType = MetatypeType::get (instanceObjectTy);
6111
- auto result = performMemberLookup (
6112
- constraintKind, memberName, metaObjectType,
6113
- functionRefKind, memberLocator, includeInaccessibleMembers);
6114
- result.numImplicitOptionalUnwraps = optionals.size ();
6115
- result.actualBaseType = metaObjectType;
6116
- return result;
6117
- }
6118
-
6119
6119
// If we have no viable or unviable candidates, and we're generating,
6120
6120
// diagnostics, rerun the query with inaccessible members included, so we can
6121
6121
// include them in the unviable candidates list.
0 commit comments