Skip to content

Commit 7577496

Browse files
committed
[Sema] Record type of identity key paths in the constraint system
If we are completing e.g. `\.self.#^COMPLETE^#` we use the type of `self` as the base type for the completion. In order to retrieve that, we need to record the type. Fixes rdar://80271346 [SR-14887]
1 parent 4cd2bb6 commit 7577496

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/Sema/CSGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3232,7 +3232,7 @@ namespace {
32323232
break;
32333233
}
32343234
case KeyPathExpr::Component::Kind::Identity:
3235-
continue;
3235+
break;
32363236
case KeyPathExpr::Component::Kind::DictionaryKey:
32373237
llvm_unreachable("DictionaryKey only valid in #keyPath");
32383238
break;

test/IDE/complete_swift_key_path.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GENERIC_KEY_PATH_BASE | %FileCheck %s -check-prefix=PERSONTYPE-DOT
3636
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GENERIC_KEY_PATH_RESULT | %FileCheck %s -check-prefix=PERSONTYPE-DOT
3737

38+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=COMPLETE_AFTER_SELF | %FileCheck %s -check-prefix=OBJ-NODOT
3839
class Person {
3940
var name: String
4041
var friends: [Person] = []
@@ -191,3 +192,7 @@ func genericKeyPathResult<KeyPathResult>(id: KeyPath<Person, KeyPathResult>) {
191192
genericKeyPathResult(\.#^GENERIC_KEY_PATH_RESULT^#)
192193
// Same as TYPE_DOT.
193194
}
195+
196+
func completeAfterSelf(people: [Person]) {
197+
people.map(\.self#^COMPLETE_AFTER_SELF^#)
198+
}

0 commit comments

Comments
 (0)