File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
validation-test/Sema/type_checker_crashers_fixed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments