@@ -3023,6 +3023,7 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM,
3023
3023
}
3024
3024
}
3025
3025
3026
+ auto Target = SGM.getASTContext ().LangOpts .Target ;
3026
3027
auto genericSig =
3027
3028
genericEnv ? genericEnv->getGenericSignature ().getCanonicalSignature ()
3028
3029
: nullptr ;
@@ -3031,6 +3032,14 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM,
3031
3032
genericEnv = nullptr ;
3032
3033
}
3033
3034
3035
+ // Add empty generic type parameter to match function signature on WebAssembly
3036
+ if (!genericSig && Target.isOSBinFormatWasm ()) {
3037
+ auto param = GenericTypeParamType::get (false , 0 , 0 , SGM.getASTContext ());
3038
+ auto sig = GenericSignature::get (param, { });
3039
+ genericSig = CanGenericSignature (sig);
3040
+ genericEnv = sig.getGenericEnvironment ();
3041
+ }
3042
+
3034
3043
// Build the signature of the thunk as expected by the keypath runtime.
3035
3044
auto signature = [&]() {
3036
3045
CanType loweredBaseTy, loweredPropTy;
@@ -3046,7 +3055,8 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM,
3046
3055
SmallVector<SILParameterInfo, 2 > params;
3047
3056
params.push_back ({loweredBaseTy, paramConvention});
3048
3057
auto &C = SGM.getASTContext ();
3049
- if (!indexes.empty ())
3058
+ // Always take indexes parameter to match callee and caller signature on WebAssembly
3059
+ if (!indexes.empty () || C.LangOpts .Target .isOSBinFormatWasm ())
3050
3060
params.push_back ({C.getUnsafeRawPointerType ()->getCanonicalType (),
3051
3061
ParameterConvention::Direct_Unowned});
3052
3062
@@ -3106,7 +3116,8 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM,
3106
3116
}
3107
3117
auto baseArg = entry->createFunctionArgument (baseArgTy);
3108
3118
SILValue indexPtrArg;
3109
- if (!indexes.empty ()) {
3119
+ // Always take indexes parameter to match callee and caller signature on WebAssembly
3120
+ if (!indexes.empty () || Target.isOSBinFormatWasm ()) {
3110
3121
auto indexArgTy =
3111
3122
subSGF.silConv .getSILType (signature->getParameters ()[1 ], signature,
3112
3123
subSGF.F .getTypeExpansionContext ());
@@ -3196,6 +3207,7 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM,
3196
3207
}
3197
3208
}
3198
3209
3210
+ auto Target = SGM.getASTContext ().LangOpts .Target ;
3199
3211
auto genericSig =
3200
3212
genericEnv ? genericEnv->getGenericSignature ().getCanonicalSignature ()
3201
3213
: nullptr ;
@@ -3204,6 +3216,14 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM,
3204
3216
genericEnv = nullptr ;
3205
3217
}
3206
3218
3219
+ // Add empty generic type parameter to match function signature on WebAssembly
3220
+ if (!genericSig && Target.isOSBinFormatWasm ()) {
3221
+ auto param = GenericTypeParamType::get (false , 0 , 0 , SGM.getASTContext ());
3222
+ auto sig = GenericSignature::get (param, { });
3223
+ genericSig = CanGenericSignature (sig);
3224
+ genericEnv = sig.getGenericEnvironment ();
3225
+ }
3226
+
3207
3227
// Build the signature of the thunk as expected by the keypath runtime.
3208
3228
auto signature = [&]() {
3209
3229
CanType loweredBaseTy, loweredPropTy;
@@ -3229,7 +3249,8 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM,
3229
3249
? ParameterConvention::Indirect_Inout
3230
3250
: paramConvention});
3231
3251
// indexes
3232
- if (!indexes.empty ())
3252
+ // Always take indexes parameter to match callee and caller signature on WebAssembly
3253
+ if (!indexes.empty () || C.LangOpts .Target .isOSBinFormatWasm ())
3233
3254
params.push_back ({C.getUnsafeRawPointerType ()->getCanonicalType (),
3234
3255
ParameterConvention::Direct_Unowned});
3235
3256
@@ -3285,7 +3306,8 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM,
3285
3306
auto baseArg = entry->createFunctionArgument (baseArgTy);
3286
3307
SILValue indexPtrArg;
3287
3308
3288
- if (!indexes.empty ()) {
3309
+ // Always take indexes parameter to match callee and caller signature on WebAssembly
3310
+ if (!indexes.empty () || Target.isOSBinFormatWasm ()) {
3289
3311
auto indexArgTy =
3290
3312
subSGF.silConv .getSILType (signature->getParameters ()[2 ], signature,
3291
3313
subSGF.getTypeExpansionContext ());
@@ -3378,6 +3400,7 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM,
3378
3400
return ;
3379
3401
}
3380
3402
3403
+ auto Target = SGM.getASTContext ().LangOpts .Target ;
3381
3404
auto genericSig =
3382
3405
genericEnv ? genericEnv->getGenericSignature ().getCanonicalSignature ()
3383
3406
: nullptr ;
@@ -3387,6 +3410,14 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM,
3387
3410
genericEnv = nullptr ;
3388
3411
}
3389
3412
3413
+ // Add empty generic type parameter to match function signature on WebAssembly
3414
+ if (!genericSig && Target.isOSBinFormatWasm ()) {
3415
+ auto param = GenericTypeParamType::get (false , 0 , 0 , SGM.getASTContext ());
3416
+ auto sig = GenericSignature::get (param, { });
3417
+ genericSig = CanGenericSignature (sig);
3418
+ genericEnv = sig.getGenericEnvironment ();
3419
+ }
3420
+
3390
3421
auto &C = SGM.getASTContext ();
3391
3422
auto unsafeRawPointerTy = C.getUnsafeRawPointerType ()->getCanonicalType ();
3392
3423
auto boolTy = C.getBoolType ()->getCanonicalType ();
0 commit comments