@@ -373,7 +373,8 @@ makeEnumRawValueConstructor(ClangImporter::Implementation &Impl,
373
373
auto allocFnTy = FunctionType::get (metaTy, fnTy);
374
374
auto initFnTy = FunctionType::get (enumTy, fnTy);
375
375
ctorDecl->setType (allocFnTy);
376
- ctorDecl->setInitializerType (initFnTy);
376
+ ctorDecl->setInterfaceType (allocFnTy);
377
+ ctorDecl->setInitializerInterfaceType (initFnTy);
377
378
378
379
// Don't bother synthesizing the body if we've already finished type-checking.
379
380
if (Impl.hasFinishedTypeChecking ())
@@ -428,8 +429,13 @@ static FuncDecl *makeEnumRawValueGetter(ClangImporter::Implementation &Impl,
428
429
/* GenericParams=*/ nullptr , params, Type (),
429
430
TypeLoc::withoutLoc (enumDecl->getRawType ()), enumDecl);
430
431
getterDecl->setImplicit ();
431
- getterDecl->setType (ParameterList::getFullInterfaceType (enumDecl->getRawType (),
432
- params, enumDecl));
432
+
433
+ auto type = ParameterList::getFullInterfaceType (enumDecl->getRawType (),
434
+ params, enumDecl);
435
+
436
+ getterDecl->setType (type);
437
+ getterDecl->setInterfaceType (type);
438
+
433
439
getterDecl->setBodyResultType (enumDecl->getRawType ());
434
440
getterDecl->setAccessibility (Accessibility::Public);
435
441
@@ -488,8 +494,13 @@ static FuncDecl *makeNewtypeBridgedRawValueGetter(
488
494
params, Type (),
489
495
TypeLoc::withoutLoc (computedType), structDecl);
490
496
getterDecl->setImplicit ();
491
- getterDecl->setType (ParameterList::getFullInterfaceType (computedType, params,
492
- structDecl));
497
+
498
+ auto type = ParameterList::getFullInterfaceType (computedType, params,
499
+ structDecl);
500
+
501
+ getterDecl->setType (type);
502
+ getterDecl->setInterfaceType (type);
503
+
493
504
getterDecl->setBodyResultType (computedType);
494
505
getterDecl->setAccessibility (Accessibility::Public);
495
506
@@ -535,8 +546,12 @@ static FuncDecl *makeFieldGetterDecl(ClangImporter::Implementation &Impl,
535
546
/* GenericParams=*/ nullptr , params, Type (),
536
547
TypeLoc::withoutLoc (getterType), importedDecl, clangNode);
537
548
getterDecl->setAccessibility (Accessibility::Public);
538
- getterDecl->setType (ParameterList::getFullInterfaceType (getterType, params,
539
- importedDecl));
549
+
550
+ auto type = ParameterList::getFullInterfaceType (getterType, params,
551
+ importedDecl);
552
+ getterDecl->setType (type);
553
+ getterDecl->setInterfaceType (type);
554
+
540
555
getterDecl->setBodyResultType (getterType);
541
556
542
557
return getterDecl;
@@ -569,8 +584,11 @@ static FuncDecl *makeFieldSetterDecl(ClangImporter::Implementation &Impl,
569
584
/* GenericParams=*/ nullptr , params, Type (),
570
585
TypeLoc::withoutLoc (voidTy), importedDecl, clangNode);
571
586
572
- setterDecl->setType (ParameterList::getFullInterfaceType (voidTy, params,
573
- importedDecl));
587
+ auto type = ParameterList::getFullInterfaceType (voidTy, params,
588
+ importedDecl);
589
+ setterDecl->setType (type);
590
+ setterDecl->setInterfaceType (type);
591
+
574
592
setterDecl->setBodyResultType (voidTy);
575
593
setterDecl->setAccessibility (Accessibility::Public);
576
594
setterDecl->setMutating ();
@@ -961,6 +979,7 @@ static bool addErrorDomain(NominalTypeDecl *swiftDecl,
961
979
/* AccessorKeywordLoc=*/ SourceLoc (),
962
980
/* GenericParams=*/ nullptr , params, toStringTy,
963
981
TypeLoc::withoutLoc (stringTy), swiftDecl);
982
+ getterDecl->setInterfaceType (toStringTy);
964
983
965
984
// Make the property decl
966
985
auto errorDomainPropertyDecl = new (C) VarDecl (
@@ -1693,7 +1712,8 @@ namespace {
1693
1712
auto allocFnTy = FunctionType::get (selfMetatype, fnTy);
1694
1713
auto initFnTy = FunctionType::get (selfType, fnTy);
1695
1714
constructor->setType (allocFnTy);
1696
- constructor->setInitializerType (initFnTy);
1715
+ constructor->setInterfaceType (allocFnTy);
1716
+ constructor->setInitializerInterfaceType (initFnTy);
1697
1717
1698
1718
constructor->setAccessibility (Accessibility::Public);
1699
1719
@@ -1949,7 +1969,8 @@ namespace {
1949
1969
auto allocFnTy = FunctionType::get (selfMetatype, fnTy);
1950
1970
auto initFnTy = FunctionType::get (selfType, fnTy);
1951
1971
constructor->setType (allocFnTy);
1952
- constructor->setInitializerType (initFnTy);
1972
+ constructor->setInterfaceType (allocFnTy);
1973
+ constructor->setInitializerInterfaceType (initFnTy);
1953
1974
1954
1975
constructor->setAccessibility (Accessibility::Public);
1955
1976
@@ -2885,9 +2906,12 @@ namespace {
2885
2906
Type argType = parameterList->getType (Impl.SwiftContext );
2886
2907
Type fnType = FunctionType::get (argType, resultType);
2887
2908
Type selfType = selfParam->getType ();
2888
- result->setInitializerType (FunctionType::get (selfType, fnType));
2909
+ Type initType = FunctionType::get (selfType, fnType);
2910
+ result->setInitializerInterfaceType (initType);
2889
2911
Type selfMetaType = MetatypeType::get (selfType->getInOutObjectType ());
2890
- result->setType (FunctionType::get (selfMetaType, fnType));
2912
+ Type allocType = FunctionType::get (selfMetaType, fnType);
2913
+ result->setType (allocType);
2914
+ result->setInterfaceType (allocType);
2891
2915
2892
2916
finishFuncDecl (decl, result);
2893
2917
return result;
@@ -2951,16 +2975,12 @@ namespace {
2951
2975
/* GenericParams=*/ nullptr , bodyParams, Type (),
2952
2976
TypeLoc::withoutLoc (swiftResultTy), dc, decl);
2953
2977
2954
- if (auto proto = dc->getAsProtocolOrProtocolExtensionContext ()) {
2955
- Type interfaceType;
2956
- std::tie (fnType, interfaceType) =
2957
- getGenericMethodType (proto, fnType->castTo <AnyFunctionType>());
2958
- result->setType (fnType);
2959
- result->setInterfaceType (interfaceType);
2960
- result->setGenericSignature (proto->getGenericSignature ());
2961
- } else {
2962
- result->setType (fnType);
2963
- }
2978
+ Type interfaceType;
2979
+ std::tie (fnType, interfaceType) =
2980
+ getGenericMethodType (dc, fnType->castTo <AnyFunctionType>());
2981
+ result->setType (fnType);
2982
+ result->setInterfaceType (interfaceType);
2983
+ result->setGenericSignature (dc->getGenericSignatureOfContext ());
2964
2984
2965
2985
result->setBodyResultType (swiftResultTy);
2966
2986
result->setAccessibility (Accessibility::Public);
@@ -3250,6 +3270,7 @@ namespace {
3250
3270
/* GenericParams=*/ nullptr , bodyParams, type,
3251
3271
TypeLoc::withoutLoc (resultTy), dc, decl);
3252
3272
3273
+ result->setInterfaceType (type);
3253
3274
result->setBodyResultType (resultTy);
3254
3275
3255
3276
result->setAccessibility (Accessibility::Public);
@@ -3734,10 +3755,8 @@ namespace {
3734
3755
// Add the 'self' parameter to the function type.
3735
3756
type = FunctionType::get (selfInterfaceType, type);
3736
3757
3737
- if (dc->isGenericContext ()) {
3738
- std::tie (type, interfaceType)
3739
- = getGenericMethodType (dc, type->castTo <AnyFunctionType>());
3740
- }
3758
+ std::tie (type, interfaceType)
3759
+ = getGenericMethodType (dc, type->castTo <AnyFunctionType>());
3741
3760
3742
3761
result->setBodyResultType (resultTy);
3743
3762
result->setType (type);
@@ -4207,21 +4226,18 @@ namespace {
4207
4226
addObjCAttribute (result, selector);
4208
4227
4209
4228
// Calculate the function type of the result.
4210
- if (dc->isGenericContext ()) {
4211
- Type interfaceAllocType;
4212
- Type interfaceInitType;
4213
- std::tie (allocType, interfaceAllocType)
4214
- = getGenericMethodType (dc, allocType->castTo <AnyFunctionType>());
4215
- std::tie (initType, interfaceInitType)
4216
- = getGenericMethodType (dc, initType->castTo <AnyFunctionType>());
4217
-
4218
- result->setInitializerInterfaceType (interfaceInitType);
4219
- result->setInterfaceType (interfaceAllocType);
4220
- result->setGenericSignature (dc->getGenericSignatureOfContext ());
4221
- }
4229
+ Type interfaceAllocType;
4230
+ Type interfaceInitType;
4231
+ std::tie (allocType, interfaceAllocType)
4232
+ = getGenericMethodType (dc, allocType->castTo <AnyFunctionType>());
4233
+ std::tie (initType, interfaceInitType)
4234
+ = getGenericMethodType (dc, initType->castTo <AnyFunctionType>());
4235
+
4236
+ result->setInitializerInterfaceType (interfaceInitType);
4237
+ result->setInterfaceType (interfaceAllocType);
4238
+ result->setGenericSignature (dc->getGenericSignatureOfContext ());
4222
4239
4223
4240
result->setType (allocType);
4224
- result->setInitializerType (initType);
4225
4241
4226
4242
if (implicit)
4227
4243
result->setImplicit ();
@@ -4305,6 +4321,10 @@ namespace {
4305
4321
AnyFunctionType *fnType) {
4306
4322
assert (!fnType->hasArchetype ());
4307
4323
4324
+ auto *sig = dc->getGenericSignatureOfContext ();
4325
+ if (!sig)
4326
+ return { fnType, fnType };
4327
+
4308
4328
Type inputType = ArchetypeBuilder::mapTypeIntoContext (
4309
4329
dc, fnType->getInput ());
4310
4330
Type resultType = ArchetypeBuilder::mapTypeIntoContext (
@@ -4313,7 +4333,7 @@ namespace {
4313
4333
dc->getGenericParamsOfContext ());
4314
4334
4315
4335
Type interfaceType = GenericFunctionType::get (
4316
- dc-> getGenericSignatureOfContext () ,
4336
+ sig ,
4317
4337
fnType->getInput (), fnType->getResult (),
4318
4338
AnyFunctionType::ExtInfo ());
4319
4339
@@ -4338,10 +4358,8 @@ namespace {
4338
4358
ParameterList::getFullInterfaceType (elementTy, getterArgs, dc);
4339
4359
4340
4360
Type interfaceType;
4341
- if (dc->isGenericContext ()) {
4342
- std::tie (getterType, interfaceType)
4343
- = getGenericMethodType (dc, getterType->castTo <AnyFunctionType>());
4344
- }
4361
+ std::tie (getterType, interfaceType)
4362
+ = getGenericMethodType (dc, getterType->castTo <AnyFunctionType>());
4345
4363
4346
4364
// Create the getter thunk.
4347
4365
FuncDecl *thunk = FuncDecl::create (
@@ -4409,10 +4427,8 @@ namespace {
4409
4427
dc);
4410
4428
4411
4429
Type interfaceType;
4412
- if (dc->isGenericContext ()) {
4413
- std::tie (setterType, interfaceType)
4414
- = getGenericMethodType (dc, setterType->castTo <AnyFunctionType>());
4415
- }
4430
+ std::tie (setterType, interfaceType)
4431
+ = getGenericMethodType (dc, setterType->castTo <AnyFunctionType>());
4416
4432
4417
4433
// Create the setter thunk.
4418
4434
FuncDecl *thunk = FuncDecl::create (
@@ -4769,8 +4785,12 @@ namespace {
4769
4785
subscript->makeComputed (SourceLoc (), getterThunk, setterThunk, nullptr ,
4770
4786
SourceLoc ());
4771
4787
auto indicesType = bodyParams->getType (C);
4772
-
4773
- subscript->setType (FunctionType::get (indicesType, elementTy)); // TODO: no good when generics are around
4788
+
4789
+ // TODO: no good when generics are around
4790
+ auto fnType = FunctionType::get (indicesType, elementTy);
4791
+ subscript->setType (fnType);
4792
+ subscript->setInterfaceType (fnType);
4793
+
4774
4794
addObjCAttribute (subscript, None);
4775
4795
4776
4796
// Optional subscripts in protocols.
@@ -6898,6 +6918,7 @@ ClangImporter::Implementation::createConstant(Identifier name, DeclContext *dc,
6898
6918
/* GenericParams=*/ nullptr , getterArgs,
6899
6919
getterType, TypeLoc::withoutLoc (type), dc);
6900
6920
func->setStatic (isStatic);
6921
+ func->setInterfaceType (getterType);
6901
6922
func->setBodyResultType (type);
6902
6923
func->setAccessibility (Accessibility::Public);
6903
6924
0 commit comments