Skip to content

Commit fef729a

Browse files
committed
SIL: Set witness table linkage when parsing a witness table that already exists
I discovered this while testing the new commit, since it results in fewer witness tables getting pre-declared. There was a SIL test that relied on the old behavior; I'm going to explicitly declare those witness tables as public_external to preserve behavior.
1 parent d413806 commit fef729a

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

lib/ParseSIL/ParseSIL.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6184,6 +6184,8 @@ bool SILParserTUState::parseSILWitnessTable(Parser &P) {
61846184

61856185
if (!wt)
61866186
wt = SILWitnessTable::create(M, *Linkage, theConformance);
6187+
else
6188+
wt->setLinkage(*Linkage);
61876189
wt->convertToDefinition(witnessEntries, conditionalConformances,
61886190
isSerialized);
61896191
BodyScope.reset();

test/IRGen/existential_metatypes.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ bb3:
109109
return %9 : $()
110110
}
111111

112-
sil_witness_table Int: Kindable module existential_metatypes {
112+
sil_witness_table public_external Int: Kindable module existential_metatypes {
113113
method #Kindable.kind!getter.1: @int_kind_getter_witness
114114
}
115115

116-
sil_witness_table Float: Kindable module existential_metatypes {
116+
sil_witness_table public_external Float: Kindable module existential_metatypes {
117117
method #Kindable.kind!getter.1: @float_kind_getter_witness
118118
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-sil-opt %s -module-name=witness_table_redeclare | %target-sil-opt -module-name=witness_table_redeclare | %FileCheck %s
2+
3+
protocol P {}
4+
5+
struct S : P {}
6+
7+
sil_witness_table S: P module witness_table_redeclare
8+
9+
sil_witness_table S: P module witness_table_redeclare {}
10+
11+
// CHECK-LABEL: sil_witness_table S: P module witness_table_redeclare {
12+
// CHECK-NEXT: }

0 commit comments

Comments
 (0)