@@ -173,6 +173,8 @@ SILModule::lookUpWitnessTable(const ProtocolConformance *C,
173
173
bool deserializeLazily) {
174
174
assert (C && " null conformance passed to lookUpWitnessTable" );
175
175
176
+ SILWitnessTable *wtable;
177
+
176
178
auto rootC = C->getRootConformance ();
177
179
// Attempt to lookup the witness table from the table.
178
180
auto found = WitnessTableMap.find (rootC);
@@ -190,16 +192,22 @@ SILModule::lookUpWitnessTable(const ProtocolConformance *C,
190
192
" Found witness table that is not"
191
193
" in the witness table lookup cache." );
192
194
#endif
193
- return nullptr ;
194
- }
195
195
196
- SILWitnessTable *wtable = found->second ;
197
- assert (wtable != nullptr && " Should never map a conformance to a null witness"
198
- " table." );
196
+ // If we don't have a witness table and we're not going to try
197
+ // deserializing it, do not create a declaration.
198
+ if (!deserializeLazily)
199
+ return nullptr ;
199
200
200
- // If we have a definition, return it.
201
- if (wtable->isDefinition ())
202
- return wtable;
201
+ wtable = createWitnessTableDeclaration (C);
202
+ } else {
203
+ wtable = found->second ;
204
+ assert (wtable != nullptr && " Should never map a conformance to a null witness"
205
+ " table." );
206
+
207
+ // If we have a definition, return it.
208
+ if (wtable->isDefinition ())
209
+ return wtable;
210
+ }
203
211
204
212
// If the module is at or past the Lowered stage, then we can't do any
205
213
// further deserialization, since pre-IRGen SIL lowering changes the types
0 commit comments