@@ -277,22 +277,17 @@ struct SynthesizedExtensionAnalyzer::Implementation {
277
277
using MergeGroupVector = std::vector<ExtensionMergeGroup>;
278
278
279
279
NominalTypeDecl *Target;
280
- Type BaseType;
281
280
DeclContext *DC;
282
281
bool IncludeUnconditional;
283
282
PrintOptions Options;
284
283
MergeGroupVector AllGroups;
285
284
ExtensionInfoMap InfoMap;
286
285
287
- Implementation (NominalTypeDecl *Target,
288
- bool IncludeUnconditional,
289
- PrintOptions &&Options):
290
- Target (Target),
291
- BaseType (Target->getDeclaredInterfaceType ()),
292
- DC(Target),
293
- IncludeUnconditional(IncludeUnconditional),
294
- Options(std::move(Options)), AllGroups(MergeGroupVector()),
295
- InfoMap(collectSynthesizedExtensionInfo(AllGroups)) {}
286
+ Implementation (NominalTypeDecl *Target, bool IncludeUnconditional,
287
+ PrintOptions &&Options)
288
+ : Target(Target), DC(Target), IncludeUnconditional(IncludeUnconditional),
289
+ Options (std::move(Options)), AllGroups(MergeGroupVector()),
290
+ InfoMap(collectSynthesizedExtensionInfo(AllGroups)) {}
296
291
297
292
unsigned countInherits (ExtensionDecl *ED) {
298
293
SmallVector<InheritedEntry, 4 > Results;
@@ -316,9 +311,9 @@ struct SynthesizedExtensionAnalyzer::Implementation {
316
311
// extension SomeType: SomeProtocol where T: SomeProtocol {}. The former is
317
312
// Ext and the latter is EnablingExt/Conf. Either of these can be
318
313
// conditional in ways that need to be considered when merging.
319
- auto conformanceIsConditional =
320
- Conf && !Conf->getConditionalRequirements ().empty ();
321
- if (!Ext->isConstrainedExtension () && !conformanceIsConditional ) {
314
+ auto isConditionalEnablingExt =
315
+ Conf && EnablingExt && !Conf->getConditionalRequirements ().empty ();
316
+ if (!Ext->isConstrainedExtension () && !isConditionalEnablingExt ) {
322
317
if (IncludeUnconditional)
323
318
Result.Ext = Ext;
324
319
return {Result, MergeInfo};
@@ -330,9 +325,9 @@ struct SynthesizedExtensionAnalyzer::Implementation {
330
325
// Substitute the base conforming type into a protocol's generic signature
331
326
// if needed.
332
327
SubstitutionMap subMap;
333
- if (!BaseType-> is <ProtocolType>() && BaseProto) {
334
- subMap = SubstitutionMap::get (BaseProto-> getGenericSignature (),
335
- {BaseType}, LookUpConformanceInModule ( ));
328
+ if (Conf && BaseProto) {
329
+ subMap = SubstitutionMap::getProtocolSubstitutions (
330
+ ProtocolConformanceRef (Conf ));
336
331
}
337
332
for (auto Req : Reqs) {
338
333
// Skip protocol's Self : <Protocol> requirement.
@@ -407,7 +402,7 @@ struct SynthesizedExtensionAnalyzer::Implementation {
407
402
return {Result, MergeInfo};
408
403
}
409
404
410
- if (Conf ) {
405
+ if (isConditionalEnablingExt ) {
411
406
if (handleRequirements (EnablingExt, Conf->getConditionalRequirements ()))
412
407
return {Result, MergeInfo};
413
408
}
@@ -509,7 +504,7 @@ struct SynthesizedExtensionAnalyzer::Implementation {
509
504
continue ;
510
505
511
506
for (auto *E : Conf->getProtocol ()->getExtensions ())
512
- handleExtension (E, true , nullptr , nullptr );
507
+ handleExtension (E, true , nullptr , Conf );
513
508
}
514
509
515
510
// Merge with actual extensions.
0 commit comments