@@ -152,73 +152,6 @@ operator()(CanType dependentType, Type conformingReplacementType,
152
152
conformingReplacementType, conformedProtocol);
153
153
}
154
154
155
- static Type substGenericFunctionType (GenericFunctionType *genericFnType,
156
- InFlightSubstitution &IFS) {
157
- // Substitute into the function type (without generic signature).
158
- auto *bareFnType = FunctionType::get (genericFnType->getParams (),
159
- genericFnType->getResult (),
160
- genericFnType->getExtInfo ());
161
- Type result = Type (bareFnType).subst (IFS);
162
- if (!result || result->is <ErrorType>()) return result;
163
-
164
- auto *fnType = result->castTo <FunctionType>();
165
- // Substitute generic parameters.
166
- bool anySemanticChanges = false ;
167
- SmallVector<GenericTypeParamType *, 2 > genericParams;
168
- for (auto param : genericFnType->getGenericParams ()) {
169
- Type paramTy = Type (param).subst (IFS);
170
- if (!paramTy)
171
- return Type ();
172
-
173
- if (auto newParam = paramTy->getAs <GenericTypeParamType>()) {
174
- if (!newParam->isEqual (param))
175
- anySemanticChanges = true ;
176
-
177
- genericParams.push_back (newParam);
178
- } else {
179
- anySemanticChanges = true ;
180
- }
181
- }
182
-
183
- // If no generic parameters remain, this is a non-generic function type.
184
- if (genericParams.empty ())
185
- return result;
186
-
187
- // Transform requirements.
188
- SmallVector<Requirement, 2 > requirements;
189
- for (const auto &req : genericFnType->getRequirements ()) {
190
- // Substitute into the requirement.
191
- auto substReqt = req.subst (IFS);
192
-
193
- // Did anything change?
194
- if (!anySemanticChanges &&
195
- (!req.getFirstType ()->isEqual (substReqt.getFirstType ()) ||
196
- (req.getKind () != RequirementKind::Layout &&
197
- !req.getSecondType ()->isEqual (substReqt.getSecondType ())))) {
198
- anySemanticChanges = true ;
199
- }
200
-
201
- requirements.push_back (substReqt);
202
- }
203
-
204
- GenericSignature genericSig;
205
- if (anySemanticChanges) {
206
- // If there were semantic changes, we need to build a new generic
207
- // signature.
208
- ASTContext &ctx = genericFnType->getASTContext ();
209
- genericSig = buildGenericSignature (ctx, GenericSignature (),
210
- genericParams, requirements,
211
- /* allowInverses=*/ false );
212
- } else {
213
- // Use the mapped generic signature.
214
- genericSig = GenericSignature::get (genericParams, requirements);
215
- }
216
-
217
- // Produce the new generic function type.
218
- return GenericFunctionType::get (genericSig, fnType->getParams (),
219
- fnType->getResult (), fnType->getExtInfo ());
220
- }
221
-
222
155
InFlightSubstitution::InFlightSubstitution (TypeSubstitutionFn substType,
223
156
LookupConformanceFn lookupConformance,
224
157
SubstOptions options)
@@ -540,11 +473,8 @@ Type Type::subst(TypeSubstitutionFn substitutions,
540
473
}
541
474
542
475
Type Type::subst (InFlightSubstitution &IFS) const {
543
- // Handle substitutions into generic function types.
544
- // FIXME: This should be banned.
545
- if (auto genericFnType = getPointer ()->getAs <GenericFunctionType>()) {
546
- return substGenericFunctionType (genericFnType, IFS);
547
- }
476
+ ASSERT (!getPointer ()->getAs <GenericFunctionType>() &&
477
+ " Perhaps you want GenericFunctionType::substGenericArgs() instead" );
548
478
549
479
if (IFS.isInvariant (*this ))
550
480
return *this ;
0 commit comments