Skip to content

Commit 4b091be

Browse files
xedinahoppen
authored andcommitted
[Tests/Sema] NFC: Add a couple string interpolation test-cases
1 parent 2fd5b5f commit 4b091be

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/Sema/string_interpolations.swift

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
do {
4+
enum E: String, CaseIterable {
5+
static var allCases: [E] {
6+
[.one, .two]
7+
}
8+
9+
case one
10+
case two
11+
12+
func test(id: String) {
13+
for c in Self.allCases where id == "\(c)" { // Ok
14+
}
15+
}
16+
}
17+
}
18+
19+
do {
20+
struct Data {
21+
var text: String
22+
23+
static func fn(_: (inout Data) -> Void) {}
24+
static func fn(_: (inout Int) -> Void) {}
25+
}
26+
27+
func test<T>(_: @autoclosure () -> T) {
28+
}
29+
30+
test((1...3).map { number in Data.fn { $0.text = "\(number)" } })
31+
32+
func test_multi<T>(_: () -> T) {
33+
}
34+
35+
test_multi {
36+
let x = 1...3
37+
_ = x.map { number in
38+
Data.fn {
39+
if $0.text == "\(number)" {
40+
$0.text = "\(x)"
41+
}
42+
}
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)