File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -1434,7 +1434,9 @@ void irgen::emitFunctionPartialApplication(
1434
1434
llvm::Value *ctx = args.claimNext ();
1435
1435
if (isIndirectFormalParameter (*singleRefcountedConvention))
1436
1436
ctx = IGF.Builder .CreateLoad (ctx, IGF.IGM .getPointerAlignment ());
1437
- ctx = IGF.Builder .CreateBitCast (ctx, IGF.IGM .RefCountedPtrTy );
1437
+ // We might get a struct containing a pointer e.g type <{ %AClass* }>
1438
+ if (ctx->getType () != IGF.IGM .RefCountedPtrTy )
1439
+ ctx = IGF.coerceValue (ctx, IGF.IGM .RefCountedPtrTy , IGF.IGM .DataLayout );
1438
1440
out.add (ctx);
1439
1441
return ;
1440
1442
}
Original file line number Diff line number Diff line change @@ -528,3 +528,28 @@ bb2(%r : $()):
528
528
bb3(%v : $()):
529
529
return %v : $()
530
530
}
531
+
532
+ struct A1 {
533
+ let b: () -> ()
534
+ }
535
+
536
+ struct A2<T> {
537
+ let a: T
538
+ }
539
+
540
+ class A3 {}
541
+
542
+ sil @amethod : $@convention(method) (@in_guaranteed A2<A3>) -> (@owned A1, @error Error)
543
+
544
+ sil @repo : $@convention(thin) (@in_guaranteed A2<A3>) -> @owned @callee_guaranteed () -> (@owned A1, @error Error) {
545
+ bb0(%0 : $*A2<A3>):
546
+ %1 = load %0 : $*A2<A3>
547
+ %2 = alloc_stack $A2<A3>
548
+ store %1 to %2 : $*A2<A3>
549
+ %4 = function_ref @amethod : $@convention(method) (@in_guaranteed A2<A3>) -> (@owned A1, @error Error)
550
+ %5 = partial_apply [callee_guaranteed] %4(%2) : $@convention(method) (@in_guaranteed A2<A3>) -> (@owned A1, @error Error)
551
+ dealloc_stack %2 : $*A2<A3>
552
+ return %5 : $@callee_guaranteed () -> (@owned A1, @error Error)
553
+ }
554
+
555
+ sil_vtable A3 {}
You can’t perform that action at this time.
0 commit comments