Skip to content

Commit be204f2

Browse files
authored
Merge pull request #10779 from xedin/rdar-33135487
[QoI] Don't try to lookup members on incorrect type while diagnosing keypath components
2 parents a842c6d + c45073e commit be204f2

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)