Skip to content

Commit 5cfccda

Browse files
author
ematejska
authored
Merge pull request #10798 from xedin/rdar-33135487-4.0
[4.0] [QoI] Don't try to lookup members on incorrect type while diagnosing keypath components
2 parents 448affa + 4d5d30b commit 5cfccda

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
@@ -7537,6 +7537,8 @@ static bool diagnoseKeyPathComponents(ConstraintSystem *CS, KeyPathExpr *KPE,
75377537
auto performLookup = [&](Identifier componentName, SourceLoc componentNameLoc,
75387538
Type &lookupType) -> LookupResult {
75397539
assert(currentType && "Non-beginning state must have a type");
7540+
if (!currentType->mayHaveMembers())
7541+
return LookupResult();
75407542

75417543
// Determine the type in which the lookup should occur. If we have
75427544
// 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)