Skip to content

Commit da0525a

Browse files
committed
[IDE] Avoid building redundant substitution map
We only care about the case where we're substituting into a protocol extension, otherwise the substitution map is an identity map.
1 parent e1e0f72 commit da0525a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/IDE/IDETypeChecking.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,12 @@ struct SynthesizedExtensionAnalyzer::Implementation {
327327
auto handleRequirements = [&](ExtensionDecl *OwningExt,
328328
ArrayRef<Requirement> Reqs) {
329329
ProtocolDecl *BaseProto = OwningExt->getSelfProtocolDecl();
330-
// Get the substitutions from the generic signature of
331-
// the extension to the interface types of the base type's
332-
// declaration.
330+
// Substitute the base conforming type into a protocol's generic signature
331+
// if needed.
333332
SubstitutionMap subMap;
334-
if (!BaseType->is<ProtocolType>()) {
335-
if (auto *NTD = OwningExt->getExtendedNominal())
336-
subMap = BaseType->getContextSubstitutionMap(NTD);
333+
if (!BaseType->is<ProtocolType>() && BaseProto) {
334+
subMap = SubstitutionMap::get(BaseProto->getGenericSignature(),
335+
{BaseType}, LookUpConformanceInModule());
337336
}
338337
for (auto Req : Reqs) {
339338
// Skip protocol's Self : <Protocol> requirement.

0 commit comments

Comments
 (0)