1
- // R/UN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-inferred-signatures=on 2>&1 | %FileCheck %s
2
- // RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-inferred-signatures=on -disable-requirement-machine-concrete-contraction 2>&1 | %FileCheck %s
1
+ // RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-inferred-signatures=on 2>&1 | %FileCheck %s
3
2
4
3
// Another GenericSignatureBuilder oddity, reduced from RxSwift.
5
4
//
@@ -19,6 +18,11 @@ class GenericDelegateProxy<P : AnyObject, D> {
19
18
typealias Parent = P
20
19
typealias Delegate = D
21
20
21
+ // Here if we resolve Proxy.Parent and Proxy.Delegate to the typealiases,
22
+ // we get vacuous requirements 'P == P' and 'D == D'. By keeping both
23
+ // the substituted and original requirement, we ensure that the
24
+ // unrelated associated type 'Parent' is constrained instead.
25
+
22
26
// CHECK-LABEL: .GenericDelegateProxy.init(_:)@
23
27
// CHECK-NEXT: <P, D, Proxy where P == Proxy.[DelegateProxyType]Parent, D == Proxy.[DelegateProxyType]Delegate, Proxy : GenericDelegateProxy<P, D>, Proxy : DelegateProxyType>
24
28
init < Proxy: DelegateProxyType > ( _: Proxy . Type )
@@ -34,8 +38,21 @@ class ConcreteDelegateProxy {
34
38
typealias Parent = SomeClass
35
39
typealias Delegate = SomeStruct
36
40
41
+ // An even more esoteric edge case. Note that this one I made up; only
42
+ // the first one is relevant for compatibility with RxSwift.
43
+ //
44
+ // Here unfortunately we produce a different result from the GSB, because
45
+ // the hack for keeping both the substituted and original requirement means
46
+ // the substituted requirements become 'P == SomeClass' and 'D == SomeStruct'.
47
+ //
48
+ // The GSB does not constrain P and D in this way and instead produced the
49
+ // following minimized signature:
50
+ //
51
+ // <P, D, Proxy where P == Proxy.[DelegateProxyType]Parent, D == Proxy.[DelegateProxyType]Delegate, Proxy : ConcreteDelegateProxy, Proxy : DelegateProxyType>!
52
+
37
53
// CHECK-LABEL: .ConcreteDelegateProxy.init(_:_:_:)@
38
- // CHECK-NEXT: <P, D, Proxy where P == Proxy.[DelegateProxyType]Parent, D == Proxy.[DelegateProxyType]Delegate, Proxy : ConcreteDelegateProxy, Proxy : DelegateProxyType>
54
+ // CHECK-NEXT: <P, D, Proxy where P == SomeClass, D == SomeStruct, Proxy : ConcreteDelegateProxy, Proxy : DelegateProxyType, Proxy.[DelegateProxyType]Delegate == SomeStruct, Proxy.[DelegateProxyType]Parent == SomeClass>
55
+
39
56
init < P, D, Proxy: DelegateProxyType > ( _: P , _: D , _: Proxy . Type )
40
57
where Proxy: ConcreteDelegateProxy ,
41
58
Proxy. Parent == P ,
@@ -45,4 +62,4 @@ class ConcreteDelegateProxy {
45
62
protocol DelegateProxyType {
46
63
associatedtype Parent : AnyObject
47
64
associatedtype Delegate
48
- }
65
+ }
0 commit comments