@@ -159,7 +159,6 @@ class Callee {
159
159
};
160
160
SILValue SelfValue;
161
161
ArrayRef<Substitution> Substitutions;
162
- CanType OrigFormalOldType;
163
162
CanType OrigFormalInterfaceType;
164
163
CanAnyFunctionType SubstFormalType;
165
164
Optional<SILLocation> SpecializeLoc;
@@ -177,18 +176,11 @@ class Callee {
177
176
SILLocation L)
178
177
: kind(Kind::IndirectValue),
179
178
IndirectValue (indirectValue),
180
- OrigFormalOldType(origFormalType),
181
179
OrigFormalInterfaceType(origFormalType),
182
180
SubstFormalType(substFormalType),
183
181
Loc(L)
184
182
{}
185
183
186
- static CanAnyFunctionType getConstantFormalType (SILGenFunction &gen,
187
- SILDeclRef fn)
188
- SIL_FUNCTION_TYPE_DEPRECATED {
189
- return gen.SGM .Types .getConstantInfo (fn.atUncurryLevel (0 )).FormalType ;
190
- }
191
-
192
184
static CanAnyFunctionType getConstantFormalInterfaceType (SILGenFunction &gen,
193
185
SILDeclRef fn) {
194
186
return gen.SGM .Types .getConstantInfo (fn.atUncurryLevel (0 ))
@@ -199,7 +191,6 @@ class Callee {
199
191
CanAnyFunctionType substFormalType,
200
192
SILLocation l)
201
193
: kind(Kind::StandaloneFunction), Constant(standaloneFunction),
202
- OrigFormalOldType(getConstantFormalType(gen, standaloneFunction)),
203
194
OrigFormalInterfaceType(getConstantFormalInterfaceType(gen,
204
195
standaloneFunction)),
205
196
SubstFormalType(substFormalType),
@@ -214,7 +205,6 @@ class Callee {
214
205
CanAnyFunctionType substFormalType,
215
206
SILLocation l)
216
207
: kind(methodKind), Constant(methodName), SelfValue(selfValue),
217
- OrigFormalOldType(getConstantFormalType(gen, methodName)),
218
208
OrigFormalInterfaceType(getConstantFormalInterfaceType(gen, methodName)),
219
209
SubstFormalType(substFormalType),
220
210
Loc(l)
@@ -247,11 +237,18 @@ class Callee {
247
237
return CanType (TupleType::get (field, ctx));
248
238
}
249
239
250
- // These first two asserts will crash before they return if
251
- // they're actually wrong.
252
- assert (getArchetypeForSelf (origParamType));
253
- assert (getArchetypeForSelf (selfType));
254
240
assert (isa<MetatypeType>(origParamType) == isa<MetatypeType>(selfType));
241
+
242
+ if (auto mt = dyn_cast<MetatypeType>(origParamType))
243
+ assert (mt.getInstanceType ()->isTypeParameter ());
244
+ else
245
+ assert (origParamType->isTypeParameter ());
246
+
247
+ if (auto mt = dyn_cast<MetatypeType>(selfType))
248
+ assert (isa<ArchetypeType>(mt.getInstanceType ()));
249
+ else
250
+ assert (isa<ArchetypeType>(selfType));
251
+
255
252
return selfType;
256
253
}
257
254
@@ -290,13 +287,13 @@ class Callee {
290
287
291
288
// Add the 'self' parameter back. We want it to look like a
292
289
// substitution of the appropriate clause from the original type.
293
- auto polyFormalType = cast<PolymorphicFunctionType>(OrigFormalOldType );
290
+ auto origFormalType = cast<AnyFunctionType>(OrigFormalInterfaceType );
294
291
auto substSelfType =
295
- buildSubstSelfType (polyFormalType .getInput (), protocolSelfType, ctx);
292
+ buildSubstSelfType (origFormalType .getInput (), protocolSelfType, ctx);
296
293
297
294
auto extInfo = FunctionType::ExtInfo (FunctionType::Representation::Thin,
298
295
/* noreturn*/ false ,
299
- /* throws*/ polyFormalType ->throws ());
296
+ /* throws*/ origFormalType ->throws ());
300
297
301
298
SubstFormalType = CanFunctionType::get (substSelfType, SubstFormalType,
302
299
extInfo);
@@ -308,17 +305,18 @@ class Callee {
308
305
assert (kind == Kind::DynamicMethod);
309
306
310
307
// Drop the original self clause.
311
- CanType methodType = OrigFormalOldType ;
308
+ CanType methodType = OrigFormalInterfaceType ;
312
309
methodType = cast<AnyFunctionType>(methodType).getResult ();
313
310
314
311
// Replace it with the dynamic self type.
315
- OrigFormalOldType = OrigFormalInterfaceType
312
+ OrigFormalInterfaceType
316
313
= getDynamicMethodFormalType (SGM, SelfValue,
317
314
Constant.getDecl (),
318
315
Constant, methodType);
316
+ assert (!OrigFormalInterfaceType->hasTypeParameter ());
319
317
320
318
// Add a self clause to the substituted type.
321
- auto origFormalType = cast<AnyFunctionType>(OrigFormalOldType );
319
+ auto origFormalType = cast<AnyFunctionType>(OrigFormalInterfaceType );
322
320
auto selfType = origFormalType.getInput ();
323
321
SubstFormalType
324
322
= CanFunctionType::get (selfType, SubstFormalType,
@@ -417,7 +415,7 @@ class Callee {
417
415
}
418
416
419
417
CanType getOrigFormalType () const {
420
- return OrigFormalOldType ;
418
+ return OrigFormalInterfaceType ;
421
419
}
422
420
423
421
CanAnyFunctionType getSubstFormalType () const {
@@ -3648,11 +3646,11 @@ SILGenFunction::emitApplyOfLibraryIntrinsic(SILLocation loc,
3648
3646
ArrayRef<ManagedValue> args,
3649
3647
SGFContext ctx) {
3650
3648
auto origFormalType =
3651
- cast<AnyFunctionType>(fn->getType ()->getCanonicalType ());
3649
+ cast<AnyFunctionType>(fn->getInterfaceType ()->getCanonicalType ());
3652
3650
auto substFormalType = origFormalType;
3653
3651
if (!subs.empty ()) {
3654
- auto polyFnType = cast<PolymorphicFunctionType >(substFormalType);
3655
- auto applied = polyFnType ->substGenericArgs (SGM.SwiftModule , subs);
3652
+ auto genericFnType = cast<GenericFunctionType >(substFormalType);
3653
+ auto applied = genericFnType ->substGenericArgs (SGM.SwiftModule , subs);
3656
3654
substFormalType = cast<FunctionType>(applied->getCanonicalType ());
3657
3655
}
3658
3656
@@ -3671,7 +3669,7 @@ SILGenFunction::emitApplyOfLibraryIntrinsic(SILLocation loc,
3671
3669
== SILFunctionLanguage::Swift);
3672
3670
3673
3671
return emitApply (loc, mv, subs, args, substFnType,
3674
- AbstractionPattern (origFormalType. getResult () ),
3672
+ AbstractionPattern (origFormalType). getFunctionResultType ( ),
3675
3673
substFormalType.getResult (),
3676
3674
options, None, None, ctx);
3677
3675
}
@@ -3807,10 +3805,10 @@ emitSpecializedAccessorFunctionRef(SILGenFunction &gen,
3807
3805
SILConstantInfo constantInfo = gen.getConstantInfo (constant);
3808
3806
3809
3807
// Apply substitutions to the callee type.
3810
- CanAnyFunctionType substAccessorType = constantInfo.FormalType ;
3808
+ CanAnyFunctionType substAccessorType = constantInfo.FormalInterfaceType ;
3811
3809
if (!substitutions.empty ()) {
3812
- auto polyFn = cast<PolymorphicFunctionType >(substAccessorType);
3813
- auto substFn = polyFn ->substGenericArgs (gen.SGM .SwiftModule , substitutions);
3810
+ auto genericFn = cast<GenericFunctionType >(substAccessorType);
3811
+ auto substFn = genericFn ->substGenericArgs (gen.SGM .SwiftModule , substitutions);
3814
3812
substAccessorType = cast<FunctionType>(substFn->getCanonicalType ());
3815
3813
}
3816
3814
0 commit comments