-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix type lowering of ~Copyable and ~Escapable generics. #72866
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
Conversation
@swift-ci test |
I don't see a test case that covers this specific situation from your PR description -- how can we observe the triviality of |
Joe already wrote tests to check triviality. I reused those by adding
This raises a good point that I was planning to bring up. We have a fair amount of complexity in AbstractionPattern to recognize inverse protocols. But any of that logic could be wrong and we'll never find out about it, at least for |
@nate-chandler I can't remove the remaining uses of
Here,
That's not going to work with any type system queries, including |
@atrick Okay, I will address this in a follow-up. |
This fixes TypeLowering for ~Copyable generics, such as: struct S<T: ~Copyable>: ~Copyable { var x: T } extension S: Copyable where T: Copyable {} func foo<T>(s: S<T>) -> () Previously, TypeLowering would ignore the implicit Copyable requirement on the archetype 'T'.
Factor AbstractionPattern::conformsToKnownProtocol and lower ~Escapable using the same logic as ~Copyable. Adds support for conditionally Escapable enums. Correctly sets the SILType::isTrivial flags for conditionally escapable structs and enums in environments (extensions) that provide an Escapable conformance, such as: struct NE<E: ~Escapable> : ~Escapable {} extension NE: Escapable { func foo() -> Self { // Self is both Escapable and trivial here. self } } Fixes rdar://125950218 ([nonescapable] support conditionally escapable enums)
4bfceac
to
4f0680c
Compare
@jckarter I included a fix for AbstractionPattern::isNoncopyable in this PR. @nate-chandler I included several unit tests involving BitwiseCopyable which, ultimately, should result in trivial lowering. But it's not high enough priority to debug right now, so I left TODOs, which we may want to track in a bug report. |
@swift-ci test |
@atrick As a reminder, having conformance to BitwiseCopyable imply SIL trivial when appropriate (not always) is already tracked by rdar://123661042 and is not a correctness issue. |
This is currently blocked on a segfault in stdlib/ArrayTraps.swift.gyb on iphonesimulator-x86_64 which I haven't been able to reproduce locally |
This passes for me locally with the same build-script invocation as CI: |
@swift-ci test |
@swift-ci smoke test windows |
Factor AbstractionPattern::conformsToKnownProtocol and lower ~Escapable using the same logic as ~Copyable.
Adds support for conditionally Escapable enums.
Correctly sets the SILType::isTrivial flags for conditionally escapable structs and enums in environments (extensions) that provide an Escapable conformance, such as:
Fixes rdar://125950218 ([nonescapable] support conditionally escapable enums)