-
Notifications
You must be signed in to change notification settings - Fork 10.5k
RequirementMachine: Another silly GenericSignatureBuilder compatibility hack for concrete contraction #41935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// R/UN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-inferred-signatures=on 2>&1 | %FileCheck %s | ||
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-inferred-signatures=on -disable-requirement-machine-concrete-contraction 2>&1 | %FileCheck %s | ||
|
||
// Another GenericSignatureBuilder oddity, reduced from RxSwift. | ||
// | ||
// The requirements 'Proxy.Parent == P' and 'Proxy.Delegate == D' in the | ||
// init() below refer to both the typealias and the associated type, | ||
// despite the class being unrelated to the protocol; it just happens to | ||
// define typealiases with the same name. | ||
// | ||
// In the Requirement Machine, the concrete contraction pre-processing | ||
// pass would eagerly substitute the concrete type into these two | ||
// requirements, producing the useless requirements 'P == P' and 'D == D'. | ||
// | ||
// Make sure concrete contraction keeps these requirements as-is by | ||
// checking the generic signature with and without concrete contraction. | ||
|
||
class GenericDelegateProxy<P : AnyObject, D> { | ||
typealias Parent = P | ||
typealias Delegate = D | ||
|
||
// CHECK-LABEL: .GenericDelegateProxy.init(_:)@ | ||
// CHECK-NEXT: <P, D, Proxy where P == Proxy.[DelegateProxyType]Parent, D == Proxy.[DelegateProxyType]Delegate, Proxy : GenericDelegateProxy<P, D>, Proxy : DelegateProxyType> | ||
init<Proxy: DelegateProxyType>(_: Proxy.Type) | ||
where Proxy: GenericDelegateProxy<P, D>, | ||
Proxy.Parent == P, | ||
Proxy.Delegate == D {} | ||
} | ||
Comment on lines
+24
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trying to wrap my head around this. If the class is unrelated to the protocol, and the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated the test in #42005 |
||
|
||
class SomeClass {} | ||
struct SomeStruct {} | ||
|
||
class ConcreteDelegateProxy { | ||
typealias Parent = SomeClass | ||
typealias Delegate = SomeStruct | ||
|
||
// CHECK-LABEL: .ConcreteDelegateProxy.init(_:_:_:)@ | ||
// CHECK-NEXT: <P, D, Proxy where P == Proxy.[DelegateProxyType]Parent, D == Proxy.[DelegateProxyType]Delegate, Proxy : ConcreteDelegateProxy, Proxy : DelegateProxyType> | ||
init<P, D, Proxy: DelegateProxyType>(_: P, _: D, _: Proxy.Type) | ||
where Proxy: ConcreteDelegateProxy, | ||
Proxy.Parent == P, | ||
Proxy.Delegate == D {} | ||
} | ||
|
||
protocol DelegateProxyType { | ||
associatedtype Parent : AnyObject | ||
associatedtype Delegate | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this RUN line disabled deliberately?