@@ -263,31 +263,43 @@ static CanSILFunctionType getAccessorType(IRGenModule &IGM,
263
263
// Build generic signature that includes all contextual generic parameters.
264
264
GenericSignature signature;
265
265
{
266
- SmallVector<GenericTypeParamType *, 4 > genericParams ;
267
- SmallVector<Requirement, 4 > genericRequirements ;
266
+ SmallVector<GenericTypeParamType *, 2 > addedParameters ;
267
+ SmallVector<Requirement, 2 > addedRequirements ;
268
268
269
269
auto *actor = getDistributedActorOf (Target);
270
270
assert (actor);
271
271
272
- for ( auto *genericParam : actor-> getInnermostGenericParamTypes ()) {
273
- genericParams. push_back (genericParam) ;
272
+ unsigned targetDepth = 1 ;
273
+ unsigned targetIndex = 0 ;
274
274
275
- // and also forward all requirements this generic parameter might have.
276
- for (auto req : actor->getGenericRequirements ()) {
277
- if (req.getFirstType ()->isEqual (genericParam)) {
278
- genericRequirements.push_back (req);
279
- }
275
+ if (Target->getGenericSignature ()) {
276
+ for (auto param: Target->getGenericSignature ().getGenericParams ()) {
277
+ targetDepth = std::max (targetDepth, param->getDepth ());
278
+ targetIndex = std::max (targetIndex, param->getIndex ());
279
+ }
280
+ // Target->getGenericSignature().getInnermostGenericParams().size();
281
+ for (auto param: Target->getGenericSignature ().getInnermostGenericParams ()) {
282
+ targetDepth = std::max (targetDepth, param->getDepth ());
283
+ targetIndex = std::max (targetIndex, param->getIndex ());
284
+ }
285
+ if (!Target->getGenericSignature ().getInnermostGenericParams ().empty ()) {
286
+ targetIndex += 1 ;
280
287
}
281
288
}
282
289
283
- // Add a generic parameter `D` which stands for decoder type in the
284
- // accessor signature - `inout D`.
285
- genericParams.push_back (decoderType);
286
- // Add a requirement that decoder conforms to the expected protocol.
287
- genericRequirements.push_back (
288
- {RequirementKind::Conformance, decoderType, decoderProtocolTy});
290
+ auto decoderParamTy = GenericTypeParamType::get (
291
+ // /*isParameterPack=*/false, /*depth=*/1, /*index=*/1, Context);
292
+ /* isParameterPack=*/ false ,
293
+ targetDepth,
294
+ targetIndex,
295
+ Context);
296
+ addedParameters.push_back (decoderParamTy);
289
297
290
- signature = GenericSignature::get (genericParams, genericRequirements);
298
+ // Add a requirement that decoder conforms to the expected protocol.
299
+ addedRequirements.push_back (
300
+ {RequirementKind::Conformance, decoderParamTy, decoderProtocolTy});
301
+ signature = buildGenericSignature (Context, Target->getGenericSignature (),
302
+ addedParameters, addedRequirements);
291
303
}
292
304
293
305
auto accessorTy = GenericFunctionType::get (
0 commit comments