@@ -161,7 +161,8 @@ Optional<Type> TypeChecker::checkObjCKeyPathExpr(DeclContext *dc,
161161
162162 // Local function to perform name lookup for the current index.
163163 auto performLookup = [&](unsigned idx, Identifier componentName,
164- SourceLoc componentNameLoc) -> LookupResult {
164+ SourceLoc componentNameLoc,
165+ Type &lookupType) -> LookupResult {
165166 if (state == Beginning)
166167 return lookupUnqualified (dc, componentName, componentNameLoc);
167168
@@ -170,7 +171,6 @@ Optional<Type> TypeChecker::checkObjCKeyPathExpr(DeclContext *dc,
170171 // Determine the type in which the lookup should occur. If we have
171172 // a bridged value type, this will be the Objective-C class to
172173 // which it is bridged.
173- Type lookupType;
174174 if (auto bridgedClass = getBridgedToObjC (dc, currentType))
175175 lookupType = bridgedClass;
176176 else
@@ -210,15 +210,17 @@ Optional<Type> TypeChecker::checkObjCKeyPathExpr(DeclContext *dc,
210210 }
211211
212212 // Look for this component.
213- LookupResult lookup = performLookup (idx, componentName, componentNameLoc);
213+ Type lookupType;
214+ LookupResult lookup = performLookup (idx, componentName, componentNameLoc,
215+ lookupType);
214216
215217 // If we didn't find anything, try to apply typo-correction.
216218 bool resultsAreFromTypoCorrection = false ;
217219 if (!lookup) {
218- performTypoCorrection (dc, DeclRefKind::Ordinary, currentType ,
220+ performTypoCorrection (dc, DeclRefKind::Ordinary, lookupType ,
219221 componentName, componentNameLoc,
220- (currentType ? defaultMemberTypeLookupOptions
221- : defaultUnqualifiedLookupOptions),
222+ (lookupType ? defaultMemberTypeLookupOptions
223+ : defaultUnqualifiedLookupOptions),
222224 lookup);
223225
224226 if (currentType)
@@ -263,7 +265,7 @@ Optional<Type> TypeChecker::checkObjCKeyPathExpr(DeclContext *dc,
263265 if (resultsAreFromTypoCorrection)
264266 break ;
265267
266- if (currentType )
268+ if (lookupType )
267269 diagnose (componentNameLoc, diag::ambiguous_member_overload_set,
268270 componentName);
269271 else
@@ -325,9 +327,9 @@ Optional<Type> TypeChecker::checkObjCKeyPathExpr(DeclContext *dc,
325327 }
326328
327329 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 );
331333 } else {
332334 newType = type->getDeclaredInterfaceType ();
333335 }
0 commit comments