Skip to content

Commit 5810000

Browse files
authored
Merge pull request #41963 from CodaFi/literally-nothing
Augment Test for Confusing ExpressibleByNilLiteral Case
2 parents 5c5d2ea + b6c3ad3 commit 5810000

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/stmt/switch_nil.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,19 @@ func test() {
1212
break
1313
}
1414
}
15+
16+
struct Nilable: ExpressibleByNilLiteral {
17+
init(nilLiteral: ()) {}
18+
}
19+
20+
func testNil() {
21+
// N.B. A deeply confusing case as no conversion is performed on the `nil`
22+
// literal. Instead, the match subject is converted to `Nilable?` and compared
23+
// using ~=.
24+
switch Nilable(nilLiteral: ()) {
25+
case nil: // expected-warning {{type 'Nilable' is not optional, value can never be nil}}
26+
break
27+
default:
28+
break
29+
}
30+
}

0 commit comments

Comments
 (0)