@@ -161,7 +161,8 @@ Optional<Type> TypeChecker::checkObjCKeyPathExpr(DeclContext *dc,
161
161
162
162
// Local function to perform name lookup for the current index.
163
163
auto performLookup = [&](unsigned idx, Identifier componentName,
164
- SourceLoc componentNameLoc) -> LookupResult {
164
+ SourceLoc componentNameLoc,
165
+ Type &lookupType) -> LookupResult {
165
166
if (state == Beginning)
166
167
return lookupUnqualified (dc, componentName, componentNameLoc);
167
168
@@ -170,7 +171,6 @@ Optional<Type> TypeChecker::checkObjCKeyPathExpr(DeclContext *dc,
170
171
// Determine the type in which the lookup should occur. If we have
171
172
// a bridged value type, this will be the Objective-C class to
172
173
// which it is bridged.
173
- Type lookupType;
174
174
if (auto bridgedClass = Context.getBridgedToObjC (dc, currentType))
175
175
lookupType = bridgedClass;
176
176
else
@@ -210,15 +210,17 @@ Optional<Type> TypeChecker::checkObjCKeyPathExpr(DeclContext *dc,
210
210
}
211
211
212
212
// Look for this component.
213
- LookupResult lookup = performLookup (idx, componentName, componentNameLoc);
213
+ Type lookupType;
214
+ LookupResult lookup = performLookup (idx, componentName, componentNameLoc,
215
+ lookupType);
214
216
215
217
// If we didn't find anything, try to apply typo-correction.
216
218
bool resultsAreFromTypoCorrection = false ;
217
219
if (!lookup) {
218
- performTypoCorrection (dc, DeclRefKind::Ordinary, currentType ,
220
+ performTypoCorrection (dc, DeclRefKind::Ordinary, lookupType ,
219
221
componentName, componentNameLoc,
220
- (currentType ? defaultMemberTypeLookupOptions
221
- : defaultUnqualifiedLookupOptions),
222
+ (lookupType ? defaultMemberTypeLookupOptions
223
+ : defaultUnqualifiedLookupOptions),
222
224
lookup);
223
225
224
226
if (currentType)
@@ -263,7 +265,7 @@ Optional<Type> TypeChecker::checkObjCKeyPathExpr(DeclContext *dc,
263
265
if (resultsAreFromTypoCorrection)
264
266
break ;
265
267
266
- if (currentType )
268
+ if (lookupType )
267
269
diagnose (componentNameLoc, diag::ambiguous_member_overload_set,
268
270
componentName);
269
271
else
@@ -325,9 +327,9 @@ Optional<Type> TypeChecker::checkObjCKeyPathExpr(DeclContext *dc,
325
327
}
326
328
327
329
Type newType;
328
- if (currentType && !currentType ->isAnyObject ()) {
329
- newType = currentType ->getTypeOfMember (dc->getParentModule (), type,
330
- this );
330
+ if (lookupType && !lookupType ->isAnyObject ()) {
331
+ newType = lookupType ->getTypeOfMember (dc->getParentModule (), type,
332
+ this );
331
333
} else {
332
334
newType = type->getDeclaredInterfaceType ();
333
335
}
0 commit comments