Skip to content

Commit c1dba16

Browse files
committed
[CSDiag] Diagnose KeyPath tuple access as unsupported even when sugared
Follow-up for [SR-9213](https://bugs.swift.org/browse/SR-9213)
1 parent 853388c commit c1dba16

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6697,16 +6697,16 @@ static bool diagnoseKeyPathComponents(ConstraintSystem &CS, KeyPathExpr *KPE,
66976697
: defaultUnqualifiedLookupOptions),
66986698
corrections);
66996699

6700-
if (currentType)
6701-
if (isa<TupleType>(currentType.getPointer())) {
6700+
if (currentType) {
6701+
if (currentType->is<TupleType>()) {
67026702
TC.diagnose(KPE->getLoc(), diag::expr_keypath_unimplemented_tuple);
67036703
isInvalid = true;
67046704
break;
67056705
}
67066706
else
67076707
TC.diagnose(componentNameLoc, diag::could_not_find_type_member,
67086708
currentType, componentName);
6709-
else
6709+
} else
67106710
TC.diagnose(componentNameLoc, diag::use_unresolved_identifier,
67116711
componentName, false);
67126712

test/expr/unary/keypath/keypath-unimplemented.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,14 @@ let _: KeyPath<TupleKeypath, Int> = \TupleKeypath.labeled.foo // expected-error
2222
let _: KeyPath<TupleKeypath, String> = \TupleKeypath.labeled.bar // expected-error {{key path support for tuples is not implemented}}
2323
let _: KeyPath<TupleKeypath, Int> = \TupleKeypath.unlabeled.0 // expected-error {{key path support for tuples is not implemented}}
2424
let _: KeyPath<TupleKeypath, String> = \TupleKeypath.unlabeled.1 // expected-error {{key path support for tuples is not implemented}}
25+
26+
struct S {
27+
typealias X = (lhs: Int, rhs: Int)
28+
typealias Y = (Int, Int)
29+
30+
let x: X
31+
let y: Y
32+
}
33+
34+
let _: KeyPath<S, Int> = \S.x.lhs // expected-error {{key path support for tuples is not implemented}}
35+
let _: KeyPath<S, Int> = \S.y.0 // expected-error {{key path support for tuples is not implemented}}

0 commit comments

Comments
 (0)