Skip to content

Commit 1bafc98

Browse files
authored
Merge pull request #10909 from xedin/rdar-33044867
[QoI] Don't try to lookup members on incorrect type during Objective-C KeyPath validation
2 parents c1dc8b3 + 481401f commit 1bafc98

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/Sema/TypeCheckExprObjC.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ Optional<Type> TypeChecker::checkObjCKeyPathExpr(DeclContext *dc,
166166
return lookupUnqualified(dc, componentName, componentNameLoc);
167167

168168
assert(currentType && "Non-beginning state must have a type");
169+
if (!currentType->mayHaveMembers())
170+
return LookupResult();
169171

170172
// Determine the type in which the lookup should occur. If we have
171173
// a bridged value type, this will be the Objective-C class to
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: not %target-swift-frontend %s -typecheck
2+
3+
public class A {
4+
var property: UndeclaredType
5+
var keyPath: Any {
6+
return #keyPath(property.foo)
7+
}
8+
}
9+
10+
public class B {
11+
var property: UndeclaredType
12+
var keyPath: Any {
13+
return [#keyPath(property.foo)]
14+
}
15+
}

0 commit comments

Comments
 (0)