|
32 | 32 | using namespace swift;
|
33 | 33 | using namespace irgen;
|
34 | 34 |
|
| 35 | +static GenericEnvironment *digOutGenericEnvironment(CanType loweredType) { |
| 36 | + // Find a non-local, non-opaque archetype in the type and pull out |
| 37 | + // its generic environment. |
| 38 | + // TODO: we ought to be able to usefully minimize this |
| 39 | + |
| 40 | + GenericEnvironment *env = nullptr; |
| 41 | + loweredType.findIf([&env](CanType t) -> bool { |
| 42 | + if (auto arch = dyn_cast<ArchetypeType>(t)) { |
| 43 | + if (!isa<PrimaryArchetypeType>(arch) && !isa<PackArchetypeType>(arch)) |
| 44 | + return false; |
| 45 | + env = arch->getGenericEnvironment(); |
| 46 | + return true; |
| 47 | + } |
| 48 | + return false; |
| 49 | + }); |
| 50 | + |
| 51 | + return env; |
| 52 | +} |
| 53 | + |
35 | 54 | OutliningMetadataCollector::OutliningMetadataCollector(
|
36 | 55 | SILType T, IRGenFunction &IGF, LayoutIsNeeded_t needsLayout,
|
37 | 56 | DeinitIsNeeded_t needsDeinitTypes)
|
@@ -141,21 +160,8 @@ irgen::getTypeAndGenericSignatureForManglingOutlineFunction(SILType type) {
|
141 | 160 | auto loweredType = type.getASTType();
|
142 | 161 | if (!loweredType->hasArchetype()) return {loweredType, nullptr};
|
143 | 162 |
|
144 |
| - // Find a non-local, non-opaque archetype in the type and pull out |
145 |
| - // its generic environment. |
146 |
| - // TODO: we ought to be able to usefully minimize this |
| 163 | + GenericEnvironment *env = digOutGenericEnvironment(loweredType); |
147 | 164 |
|
148 |
| - GenericEnvironment *env = nullptr; |
149 |
| - loweredType.findIf([&env](CanType t) -> bool { |
150 |
| - if (auto arch = dyn_cast<ArchetypeType>(t)) { |
151 |
| - if (!isa<PrimaryArchetypeType>(arch) && |
152 |
| - !isa<PackArchetypeType>(arch)) |
153 |
| - return false; |
154 |
| - env = arch->getGenericEnvironment(); |
155 |
| - return true; |
156 |
| - } |
157 |
| - return false; |
158 |
| - }); |
159 | 165 | assert(env && "has archetype but no archetype?!");
|
160 | 166 | return {loweredType->mapTypeOutOfContext()->getCanonicalType(),
|
161 | 167 | env->getGenericSignature().getCanonicalSignature()};
|
|
0 commit comments