Skip to content

Commit 5d659cf

Browse files
authored
Merge pull request #78201 from omochi/test-66041
Add regression test for fixed compiler crash
2 parents df3f45a + eb2d4b6 commit 5d659cf

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// RUN: %target-swift-frontend %s -typecheck
2+
3+
// https://github.com/apple/swift/issues/66041
4+
5+
protocol Middleware<Input, Output, NextInput, NextOutput> {
6+
associatedtype Input
7+
associatedtype Output
8+
associatedtype NextInput
9+
associatedtype NextOutput
10+
}
11+
12+
protocol Routes<Input, Output> {
13+
associatedtype Input
14+
associatedtype Output
15+
}
16+
17+
extension Routes {
18+
func compose<M>(_ middleware: M) -> any Routes<M.NextInput, M.NextOutput> where
19+
M: Middleware,
20+
M.Input == Input,
21+
M.Output == Output
22+
{
23+
fatalError()
24+
}
25+
26+
func mapInput<NewInput>(
27+
_ transform: @escaping (Input) -> NewInput
28+
) -> any Routes<NewInput, Output> {
29+
fatalError()
30+
}
31+
}
32+
33+
struct Request {}
34+
struct Response {}
35+
struct User {}
36+
37+
struct AuthMiddleware<Input, Output>: Middleware {
38+
typealias NextInput = (Input, login: User)
39+
typealias NextOutput = Output
40+
}
41+
42+
func main(routes: any Routes<Request, Response>) {
43+
let routes = routes.compose(AuthMiddleware())
44+
.mapInput {
45+
(request: $0.0, login: $0.login)
46+
}
47+
}

0 commit comments

Comments
 (0)