mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Some changes I was working on uncovered a latent bug where we would emit a class_method instruction to call an allocating initializer that did not have a vtable entry. Previously this wasn't caught because the only example of this in our test suite was in test/SILGen/objc_bridging_any.swift, which did not test with IRGen; if it did, an IRGen crash would have been observed. Factor out some code duplication to prevent this from happening again, and add a SILGen test that we emit a vtable entry in this case, and that the test case passes IRGen also.
40 lines
1.5 KiB
Swift
40 lines
1.5 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-frontend -emit-module -enable-sil-ownership %S/Inputs/objc_required_designated_init_2.swift -module-name Booms -o %t/Booms.swiftmodule -import-objc-header %S/Inputs/objc_required_designated_init.h
|
|
// RUN: %target-swift-frontend -I %t -emit-silgen -enable-sil-ownership -verify %s -import-objc-header %S/Inputs/objc_required_designated_init.h | %FileCheck %s
|
|
// RUN: %target-swift-frontend -I %t -emit-ir %s -import-objc-header %S/Inputs/objc_required_designated_init.h
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import Booms
|
|
|
|
class Baboom : Boom {
|
|
@objc dynamic required init() {
|
|
super.init()
|
|
}
|
|
}
|
|
|
|
class BigBadaBoom<V> : Badaboom<V> {
|
|
required init() {
|
|
super.init()
|
|
}
|
|
}
|
|
|
|
class Root {
|
|
@objc dynamic required init() {}
|
|
}
|
|
|
|
// CHECK-LABEL: sil_vtable Baboom {
|
|
// CHECK: #Boom.init!allocator.1: (Boom.Type) -> () -> Boom : _T029objc_required_designated_init6BaboomCACycfC [override]
|
|
// CHECK: #Baboom.deinit!deallocator: _T029objc_required_designated_init6BaboomCfD
|
|
// CHECK: }
|
|
|
|
// CHECK-LABEL: sil_vtable BigBadaBoom {
|
|
// CHECK: #Badaboom.init!allocator.1: <U> (Badaboom<U>.Type) -> () -> Badaboom<U> : _T029objc_required_designated_init11BigBadaBoomCACyxGycfC [override]
|
|
// CHECK: #BigBadaBoom.deinit!deallocator: _T029objc_required_designated_init11BigBadaBoomCfD
|
|
// CHECK: }
|
|
|
|
// CHECK-LABEL: sil_vtable Root {
|
|
// CHECK: #Root.init!allocator.1: (Root.Type) -> () -> Root : _T029objc_required_designated_init4RootCACycfC
|
|
// CHECK: #Root.deinit!deallocator: _T029objc_required_designated_init4RootCfD
|
|
// CHECK: }
|