@@ -2133,19 +2133,6 @@ static Type typeEraseExistentialSelfReferences(Type refTy, Type baseTy,
2133
2133
2134
2134
unsigned metatypeDepth = 0 ;
2135
2135
2136
- // / Check whether the given type has a reference to the generic parameter
2137
- // / that we are erasing.
2138
- auto hasErasedGenericParameter = [&](Type type) {
2139
- if (!type->hasTypeParameter ())
2140
- return false ;
2141
-
2142
- return type.findIf ([&](Type type) {
2143
- if (auto gp = type->getAs <GenericTypeParamType>())
2144
- return gp->getDepth () == 0 ;
2145
- return false ;
2146
- });
2147
- };
2148
-
2149
2136
std::function<Type (Type, TypePosition)> transformFn;
2150
2137
transformFn = [&](Type type, TypePosition initialPos) -> Type {
2151
2138
return type.transformWithPosition (
@@ -2173,7 +2160,7 @@ static Type typeEraseExistentialSelfReferences(Type refTy, Type baseTy,
2173
2160
if (auto opaque = dyn_cast<OpaqueTypeArchetypeType>(t)) {
2174
2161
for (auto replacementType :
2175
2162
opaque->getSubstitutions ().getReplacementTypes ()) {
2176
- if (hasErasedGenericParameter ( replacementType)) {
2163
+ if (replacementType-> hasTypeParameter ( )) {
2177
2164
return opaque->getExistentialType ();
2178
2165
}
2179
2166
}
@@ -2193,12 +2180,9 @@ static Type typeEraseExistentialSelfReferences(Type refTy, Type baseTy,
2193
2180
return llvm::None;
2194
2181
}
2195
2182
2196
- if (t->getRootGenericParam ()->getDepth () > 0 ) {
2197
- return Type (t);
2198
- }
2183
+ assert (t->getRootGenericParam ()->getDepth () == 0 );
2199
2184
2200
- // If the type parameter is beyond the domain of the existential
2201
- // generic signature, ignore it.
2185
+ // This can happen with invalid code.
2202
2186
if (!existentialSig->isValidTypeParameter (t)) {
2203
2187
return Type (t);
2204
2188
}
0 commit comments