Skip to content

Commit eae1466

Browse files
committed
[TypeChecker] NFC: Add a test-case for rdar://113745963
1 parent 64a654d commit eae1466

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
// rdar://113745963
4+
5+
// https://github.com/apple/swift/pull/67441 changed closure resolution order which makes the following code fail to type-check.
6+
7+
struct Date : Equatable {
8+
static var distantPast = Date()
9+
}
10+
11+
enum Request {
12+
struct Options: OptionSet {
13+
static let option1 = Options(rawValue: 1 << 0)
14+
static let option2 = Options(rawValue: 1 << 1)
15+
16+
let rawValue: Int
17+
18+
init(rawValue: Int) {
19+
self.rawValue = rawValue
20+
}
21+
}
22+
23+
enum Source : Comparable {
24+
case automatic
25+
case manual(Date)
26+
27+
static func < (lhs: Source, rhs: Source) -> Bool { true }
28+
}
29+
30+
case problem(options: Options, source: Source)
31+
}
32+
33+
enum OuterSource {
34+
case automatic, manual, unknown
35+
}
36+
37+
struct Test {
38+
func test(arr: [Int]) {
39+
let _: [Request] = arr.map { value in
40+
let source: OuterSource = .automatic
41+
let dateAdded = Date.distantPast
42+
return .problem(
43+
options: {
44+
switch source {
45+
case .automatic:
46+
return [.option1, .option2]
47+
case .manual, .unknown:
48+
return []
49+
}
50+
}(),
51+
source: {
52+
switch source {
53+
case .manual:
54+
return .manual(dateAdded)
55+
case .automatic, .unknown:
56+
return .automatic
57+
}
58+
}())
59+
}
60+
}
61+
}

0 commit comments

Comments
 (0)