mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
401d2ee072
Avoid passing an invalid substitution map into createApply. Required conditions (from the bug report): 1. `~Copyable` struct with user-defined `deinit` 2. Nested inside a constrained extension where all generic parameters are concrete 3. A `destroy_value` or `destroy_addr` of the struct's value exists in some function 4. DeinitDevirtualizer runs (release-mode optimization pipeline) Fixes rdar://173803881 ([GH:#88213] [SILOptimizer] DeinitDevirtualizer assertion failure with ~Copyable type in all-concrete constrained extension) Suggested by: coenttb
20 lines
801 B
Swift
20 lines
801 B
Swift
// RUN: %target-swift-frontend -sil-verify-all -emit-sil -O %s | %FileCheck %s
|
|
|
|
// REQUIRES: swift_in_compiler
|
|
|
|
public struct Outer<T> {}
|
|
extension Outer where T == UInt8 {
|
|
public struct InnerNC: ~Copyable {
|
|
var x: Int
|
|
deinit {}
|
|
}
|
|
}
|
|
|
|
// rdar://173803881 (~Copyable type in all-concrete constrained extension)
|
|
// The DeinitDevirtualization should not crash.
|
|
//
|
|
// CHECK-LABEL: sil @$s32moveonly_deinit_devirtualization24testConstrainedExtensionyyAA5OuterVAAs5UInt8VRszlE7InnerNCVyAF_GnF : $@convention(thin) (@owned Outer<UInt8>.InnerNC) -> () {
|
|
// CHECK-NOT: destroy
|
|
// CHECK-LABEL: } // end sil function '$s32moveonly_deinit_devirtualization24testConstrainedExtensionyyAA5OuterVAAs5UInt8VRszlE7InnerNCVyAF_GnF'
|
|
public func testConstrainedExtension(_ s: consuming Outer<UInt8>.InnerNC) {}
|