Skip to content

Commit cb98479

Browse files
author
Amritpan Kaur
committed
[NFC] Move keypath diagnostic from general to keypath
1 parent 59d2679 commit cb98479

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

test/Constraints/diagnostics.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,18 +1039,6 @@ class C2_47269 {
10391039
}
10401040
}
10411041

1042-
// rdar://problem/32101765 - Keypath diagnostics are not actionable/helpful
1043-
1044-
struct R32101765 { let prop32101765 = 0 }
1045-
let _: KeyPath<R32101765, Float> = \.prop32101765
1046-
// expected-error@-1 {{key path value type 'Int' cannot be converted to contextual type 'Float'}}
1047-
let _: KeyPath<R32101765, Float> = \R32101765.prop32101765
1048-
// expected-error@-1 {{key path value type 'Int' cannot be converted to contextual type 'Float'}}
1049-
let _: KeyPath<R32101765, Float> = \.prop32101765.unknown
1050-
// expected-error@-1 {{type 'Int' has no member 'unknown'}}
1051-
let _: KeyPath<R32101765, Float> = \R32101765.prop32101765.unknown
1052-
// expected-error@-1 {{type 'Int' has no member 'unknown'}}
1053-
10541042
// rdar://problem/32390726 - Bad Diagnostic: Don't suggest `var` to `let` when binding inside for-statement
10551043
for var i in 0..<10 { // expected-warning {{variable 'i' was never mutated; consider removing 'var' to make it constant}} {{5-9=}}
10561044
_ = i + 1

test/Constraints/keypath.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,19 @@ func test_any_key_path() {
247247
anyKP = \.v
248248
// expected-error@-1 {{cannot infer key path type from context; consider explicitly specifying a root type}}
249249
}
250+
251+
// rdar://problem/32101765 - Keypath diagnostics are not actionable/helpful
252+
func rdar32101765() {
253+
struct R32101765 {
254+
let prop32101765 = 0
255+
}
256+
257+
let _: KeyPath<R32101765, Float> = \.prop32101765
258+
// expected-error@-1 {{key path value type 'Int' cannot be converted to contextual type 'Float'}}
259+
let _: KeyPath<R32101765, Float> = \R32101765.prop32101765
260+
// expected-error@-1 {{key path value type 'Int' cannot be converted to contextual type 'Float'}}
261+
let _: KeyPath<R32101765, Float> = \.prop32101765.unknown
262+
// expected-error@-1 {{type 'Int' has no member 'unknown'}}
263+
let _: KeyPath<R32101765, Float> = \R32101765.prop32101765.unknown
264+
// expected-error@-1 {{type 'Int' has no member 'unknown'}}
265+
}

0 commit comments

Comments
 (0)