Skip to content

Commit 93f22cd

Browse files
authored
Merge pull request #34420 from slavapestov/two-regression-tests
Two regression tests
2 parents 442fc68 + acef026 commit 93f22cd

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// RUN: %target-swift-frontend -emit-ir %s
2+
3+
protocol Dismissable {
4+
func dismiss(completion: @escaping () -> Void)
5+
}
6+
7+
typealias Completion = (Dismissable?) -> Void
8+
9+
protocol Cancelable: AnyObject {
10+
func cancel()
11+
}
12+
13+
protocol Controller {
14+
func asyncThing(completion: @escaping ((_ error: Error) -> Void)) -> Cancelable
15+
}
16+
17+
public struct Message: Equatable {
18+
public static let `default` = Message()
19+
20+
public init() {
21+
}
22+
23+
public init(error: Error) {
24+
self = .default
25+
}
26+
}
27+
28+
struct PresentAlert {
29+
let message: Message
30+
}
31+
32+
class Manager {
33+
private let controller: Controller
34+
35+
init(controller: Controller) {
36+
self.controller = controller
37+
}
38+
39+
func present() {
40+
let _: Completion = { (dismissable: Dismissable?) in
41+
dismissable?.dismiss { [weak self] in
42+
guard let sself = self else { return }
43+
44+
sself.controller.asyncThing { error in
45+
let backupMessage = Message()
46+
let mainMessage = Message(error: error)
47+
let finalMessage = mainMessage != Message.default ? mainMessage : backupMessage
48+
49+
_ = PresentAlert(message: finalMessage)
50+
}.cancel()
51+
}
52+
}
53+
}
54+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %target-swift-frontend -emit-ir %s
2+
3+
protocol Projection {
4+
associatedtype Root
5+
associatedtype Path: PartialKeyPath<Root>
6+
static var path: Path { get }
7+
}
8+
9+
struct ProjectKey<Key, Value>: Projection {
10+
typealias Root = (Key, Value)
11+
typealias Path = KeyPath<(Key, Value), Key>
12+
static var path: KeyPath<(Key, Value), Key> { \.0 }
13+
}

0 commit comments

Comments
 (0)