Skip to content

Commit c45073e

Browse files
committed
[QoI] Don't try to lookup members on incorrect type while diagnosing keypath components
While trying to diagnose problems related to keypath components don't assume that type of the component is always correct, check before trying to see if it's bridged type or has members. Resolves: rdar://problem/33135487
1 parent f2dbd65 commit c45073e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7534,6 +7534,8 @@ static bool diagnoseKeyPathComponents(ConstraintSystem *CS, KeyPathExpr *KPE,
75347534
auto performLookup = [&](Identifier componentName, SourceLoc componentNameLoc,
75357535
Type &lookupType) -> LookupResult {
75367536
assert(currentType && "Non-beginning state must have a type");
7537+
if (!currentType->mayHaveMembers())
7538+
return LookupResult();
75377539

75387540
// Determine the type in which the lookup should occur. If we have
75397541
// a bridged value type, this will be the Objective-C class to
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: not %target-swift-frontend %s -typecheck
2+
3+
enum State<StateType> {
4+
func put<StateType>() -> StateType {}
5+
func put<T>(keyPath: WritableKeyPath<StateType, T>, projection: T) {
6+
put(keyPath: \.age, projection: {})
7+
}
8+
}

0 commit comments

Comments
 (0)