Skip to content

Commit 0a62be2

Browse files
committed
SIL: Use SubstitutionMap::mapIntoTypeExpansionContext() in SILTypeSubstituter
I made a mistake in 47156e0. There was a call to call to forAbstract() in SILTypeSubstituter that passed in the wrong subject ype. This call was inside SILTypeSubstituter's own implementation of replacing opaque types with underlying types in a substitution map. This duplicates an existing utility method in SubstitutionMap anyway, so let's just use that instead. Fixes rdar://149353285.
1 parent 7e59265 commit 0a62be2

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

lib/SIL/IR/SILTypeSubstitution.cpp

+1-14
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,7 @@ class SILTypeSubstituter :
6868
if (!typeExpansionContext.shouldLookThroughOpaqueTypeArchetypes())
6969
return subs;
7070

71-
return subs.subst([&](SubstitutableType *s) -> Type {
72-
return substOpaqueTypesWithUnderlyingTypes(s->getCanonicalType(),
73-
typeExpansionContext);
74-
}, [&](CanType dependentType,
75-
Type conformingReplacementType,
76-
ProtocolDecl *conformedProtocol) -> ProtocolConformanceRef {
77-
return substOpaqueTypesWithUnderlyingTypes(
78-
ProtocolConformanceRef::forAbstract(conformingReplacementType,
79-
conformedProtocol),
80-
conformingReplacementType->getCanonicalType(),
81-
typeExpansionContext);
82-
},
83-
SubstFlags::SubstituteOpaqueArchetypes |
84-
SubstFlags::PreservePackExpansionLevel);
71+
return subs.mapIntoTypeExpansionContext(typeExpansionContext);
8572
}
8673

8774
// Substitute a function type.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %target-swift-emit-silgen %s | %FileCheck %s
2+
3+
public protocol P {}
4+
5+
extension P {
6+
}
7+
8+
public struct S: P {
9+
public func callAsFunction<V>(_: () -> V) { }
10+
}
11+
12+
public func f() -> some P {
13+
S()
14+
}
15+
16+
public struct G<T: P>: P {
17+
public init(_: () -> T) {}
18+
}
19+
20+
S() {
21+
return G { return f() }
22+
}
23+

0 commit comments

Comments
 (0)