mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The witness table had shared linkage, but we weren't serializing them, which would cause linking errors if we emitted a reference to such a witness table from a different module than the one where it was first defined, as a result of deserializing and optimizing SIL. This issue was introduced when SIL witness table serialization was made conditional on the -sil-serialize-witness-tables flag, which is normally only enabled for the standard library. When the flag was added, existing tests were updated to pass the flag, which masked the issue. Remove the flag from existing tests, ensure that imported witness tables are still [serialized], and add a new test specifically for the behavior enabled by this flag.
53 lines
2.2 KiB
Swift
53 lines
2.2 KiB
Swift
// RUN: %target-swift-frontend -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-silgen -enable-sil-ownership > %t.out
|
|
// RUN: %FileCheck -check-prefix=CHECK -check-prefix=CHECK-%target-ptrsize %s < %t.out
|
|
// RUN: %FileCheck -check-prefix=NEGATIVE %s < %t.out
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import gizmo
|
|
|
|
|
|
// CHECK-DAG: sil shared [serializable] @_T0SC16NSRuncingOptionsO{{[_0-9a-zA-Z]*}}fC
|
|
// CHECK-DAG: sil shared [serializable] @_T0SC16NSRuncingOptionsO8rawValueSivg
|
|
// CHECK-DAG: sil shared [serializable] @_T0SC16NSRuncingOptionsO9hashValueSivg
|
|
|
|
// Non-payload enum ctors don't need to be instantiated at all.
|
|
// NEGATIVE-NOT: sil shared [transparent] @_T0SC16NSRuncingOptionsO5MinceAbBmF
|
|
// NEGATIVE-NOT: sil shared [transparent] @_T0SC16NSRuncingOptionsO12QuinceSlicedAbBmF
|
|
// NEGATIVE-NOT: sil shared [transparent] @_T0SC16NSRuncingOptionsO15QuinceJuliennedAbBmF
|
|
// NEGATIVE-NOT: sil shared [transparent] @_T0SC16NSRuncingOptionsO11QuinceDicedAbBmF
|
|
|
|
var runcing: NSRuncingOptions = .mince
|
|
|
|
var raw = runcing.rawValue
|
|
var eq = runcing == .quinceSliced
|
|
var hash = runcing.hashValue
|
|
|
|
func testEm<E: Equatable>(_ x: E, _ y: E) {}
|
|
func hashEm<H: Hashable>(_ x: H) {}
|
|
func rawEm<R: RawRepresentable>(_ x: R) {}
|
|
|
|
testEm(NSRuncingOptions.mince, .quinceSliced)
|
|
hashEm(NSRuncingOptions.mince)
|
|
rawEm(NSRuncingOptions.mince)
|
|
rawEm(NSFungingMask.asset)
|
|
|
|
protocol Bub {}
|
|
|
|
extension NSRuncingOptions: Bub {}
|
|
|
|
// CHECK-32-DAG: integer_literal $Builtin.Int2048, -2147483648
|
|
// CHECK-64-DAG: integer_literal $Builtin.Int2048, 2147483648
|
|
_ = NSFungingMask.toTheMax
|
|
|
|
// CHECK-DAG: sil_witness_table shared [serialized] NSRuncingOptions: RawRepresentable module gizmo
|
|
// CHECK-DAG: sil_witness_table shared [serialized] NSRuncingOptions: Equatable module gizmo
|
|
// CHECK-DAG: sil_witness_table shared [serialized] NSRuncingOptions: Hashable module gizmo
|
|
// CHECK-DAG: sil_witness_table shared [serialized] NSFungingMask: RawRepresentable module gizmo
|
|
|
|
// CHECK-DAG: sil shared [transparent] [serialized] [thunk] @_T0SC16NSRuncingOptionsOs16RawRepresentable5gizmosACP{{[_0-9a-zA-Z]*}}fCTW
|
|
|
|
// Extension conformances get linkage according to the protocol's accessibility, as normal.
|
|
// CHECK-DAG: sil_witness_table hidden NSRuncingOptions: Bub module objc_enum
|
|
|