Skip to content

Commit 9efd87e

Browse files
committed
Add test.
1 parent d6d59ee commit 9efd87e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/Sema/struct_key_path_iterable.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,26 @@ struct DummyOptimizer<P : KeyPathIterable, Scalar : BinaryFloatingPoint>
114114
}
115115
}
116116

117+
// TF-575: Test overloaded key path component name.
118+
protocol NameLookupConflictProtocol {}
119+
extension NameLookupConflictProtocol {
120+
func member() {}
121+
}
122+
struct NameLookupConflict: NameLookupConflictProtocol & KeyPathIterable {
123+
// Note: `NameLookupConflict.member` is overloaded with
124+
// `MemberNameConflictProtocol.member`.
125+
// This makes the following generated code fail:
126+
//
127+
// var allKeyPaths: [PartialKeyPath<Self>] {
128+
// [\Self.member]
129+
// }
130+
//
131+
// error: cannot convert value of type
132+
// 'WritableKeyPath<NameLookupConflict, Float>' to expected element type
133+
// 'PartialKeyPath<NameLookupConflict>'
134+
var member: Float
135+
}
136+
117137
// Test derived conformances in disallowed contexts.
118138

119139
// expected-error @+3 {{type 'OtherFileNonconforming' does not conform to protocol 'KeyPathIterable'}}

0 commit comments

Comments
 (0)