mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Collapse the generic witness table, which was used only as a uniquing data structure during witness table instantiation, into the protocol conformance record. This colocates all of the constant protocol conformance metadata and makes it possible for us to recover the generic witness table from the conformance descriptor (including looking at the pattern itself). Rename swift_getGenericWitnessTable() to swift_instantiateWitnessTable() to make it clearer what its purpose is, and take the conformance descriptor directly.
50 lines
1.0 KiB
Plaintext
Executable File
50 lines
1.0 KiB
Plaintext
Executable File
// RUN: %target-swift-frontend %s -module-name=test -emit-ir | %FileCheck %s
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
import Swift
|
|
import SwiftShims
|
|
|
|
protocol P {
|
|
}
|
|
|
|
struct PBox<T> where T : P {
|
|
init()
|
|
}
|
|
|
|
protocol HasSimpleAssoc {
|
|
associatedtype Assoc
|
|
}
|
|
|
|
protocol DerivedFromSimpleAssoc : HasSimpleAssoc {
|
|
}
|
|
|
|
struct GenericComputed<T> : DerivedFromSimpleAssoc where T : P {
|
|
typealias Assoc = PBox<T>
|
|
init()
|
|
}
|
|
|
|
sil_witness_table shared [serialized] <T where T : P> GenericComputed<T>: DerivedFromSimpleAssoc module nix {
|
|
base_protocol HasSimpleAssoc: <T where T : P> GenericComputed<T>: HasSimpleAssoc module nix
|
|
}
|
|
|
|
sil_witness_table shared [serialized] <T where T : P> GenericComputed<T>: HasSimpleAssoc module nix {
|
|
associated_type Assoc: PBox<T>
|
|
}
|
|
|
|
sil_default_witness_table hidden P {
|
|
}
|
|
|
|
sil_default_witness_table hidden HasSimpleAssoc {
|
|
no_default
|
|
}
|
|
|
|
sil_default_witness_table hidden DerivedFromSimpleAssoc {
|
|
no_default
|
|
}
|
|
|
|
// CHECK: define internal void @"$s4test15GenericComputedVyxGAA22DerivedFromSimpleAssocAAWI"
|
|
|
|
|