@@ -3169,22 +3169,26 @@ static GenericWitnessTableCache &getCache(GenericWitnessTable *gen) {
3169
3169
// / If there's no initializer, no private storage, and all requirements
3170
3170
// / are present, we don't have to instantiate anything; just return the
3171
3171
// / witness table template.
3172
- // /
3173
- // / Most of the time IRGen should be able to determine this statically;
3174
- // / the one case is with resilient conformances, where the resilient
3175
- // / protocol has not yet changed in a way that's incompatible with the
3176
- // / conformance.
3177
3172
static bool doesNotRequireInstantiation (GenericWitnessTable *genericTable) {
3178
- if (genericTable->Instantiator .isNull () &&
3179
- genericTable->ResilientWitnesses .isNull () &&
3180
- genericTable->WitnessTablePrivateSizeInWords == 0 &&
3181
- genericTable->WitnessTableSizeInWords ==
3182
- (genericTable->Protocol ->NumRequirements +
3183
- WitnessTableFirstRequirementOffset)) {
3184
- return true ;
3173
+ // If we have resilient witnesses, we require instantiation.
3174
+ if (!genericTable->ResilientWitnesses .isNull ()) {
3175
+ return false ;
3185
3176
}
3186
3177
3187
- return false ;
3178
+ // If we don't have resilient witnesses, the template must provide
3179
+ // everything.
3180
+ assert (genericTable->WitnessTableSizeInWords ==
3181
+ (genericTable->Protocol ->NumRequirements +
3182
+ WitnessTableFirstRequirementOffset));
3183
+
3184
+ // If we have an instantiation function or private data, we require
3185
+ // instantiation.
3186
+ if (!genericTable->Instantiator .isNull () ||
3187
+ genericTable->WitnessTablePrivateSizeInWords > 0 ) {
3188
+ return false ;
3189
+ }
3190
+
3191
+ return true ;
3188
3192
}
3189
3193
3190
3194
// / Initialize witness table entries from order independent resilient
@@ -3260,7 +3264,6 @@ WitnessTableCacheEntry::allocate(GenericWitnessTable *genericTable,
3260
3264
// negative offsets.
3261
3265
auto table = fullTable + privateSizeInWords;
3262
3266
auto pattern = reinterpret_cast <void * const *>(&*genericTable->Pattern );
3263
- auto requirements = protocol->Requirements .get ();
3264
3267
3265
3268
// Fill in the provided part of the requirements from the pattern.
3266
3269
for (size_t i = 0 , e = numPatternWitnesses; i < e; ++i) {
@@ -3270,16 +3273,6 @@ WitnessTableCacheEntry::allocate(GenericWitnessTable *genericTable,
3270
3273
// Fill in any default requirements.
3271
3274
if (genericTable->ResilientWitnesses )
3272
3275
initializeResilientWitnessTable (genericTable, table);
3273
- else {
3274
- for (size_t i = numPatternWitnesses, e = numRequirements; i < e; ++i) {
3275
- size_t requirementIndex = i - WitnessTableFirstRequirementOffset;
3276
- void *defaultImpl =
3277
- requirements[requirementIndex].DefaultImplementation .get ();
3278
- assert (defaultImpl &&
3279
- " no default implementation for missing requirement" );
3280
- table[i] = defaultImpl;
3281
- }
3282
- }
3283
3276
3284
3277
auto castTable = reinterpret_cast <WitnessTable*>(table);
3285
3278
0 commit comments