File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -1434,7 +1434,12 @@ 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 ()->isPointerTy ())
1439
+ ctx = IGF.coerceValue (ctx, IGF.IGM .RefCountedPtrTy ,
1440
+ IGF.IGM .DataLayout );
1441
+ else
1442
+ ctx = IGF.Builder .CreateBitCast (ctx, IGF.IGM .RefCountedPtrTy );
1438
1443
out.add (ctx);
1439
1444
return ;
1440
1445
}
Original file line number Diff line number Diff line change @@ -524,3 +524,28 @@ bb2(%r : $()):
524
524
bb3(%v : $()):
525
525
return %v : $()
526
526
}
527
+
528
+ struct A1 {
529
+ let b: () -> ()
530
+ }
531
+
532
+ struct A2<T> {
533
+ let a: T
534
+ }
535
+
536
+ class A3 {}
537
+
538
+ sil @amethod : $@convention(method) (@in_guaranteed A2<A3>) -> (@owned A1, @error Error)
539
+
540
+ sil @repo : $@convention(thin) (@in_guaranteed A2<A3>) -> @owned @callee_guaranteed () -> (@owned A1, @error Error) {
541
+ bb0(%0 : $*A2<A3>):
542
+ %1 = load %0 : $*A2<A3>
543
+ %2 = alloc_stack $A2<A3>
544
+ store %1 to %2 : $*A2<A3>
545
+ %4 = function_ref @amethod : $@convention(method) (@in_guaranteed A2<A3>) -> (@owned A1, @error Error)
546
+ %5 = partial_apply [callee_guaranteed] %4(%2) : $@convention(method) (@in_guaranteed A2<A3>) -> (@owned A1, @error Error)
547
+ dealloc_stack %2 : $*A2<A3>
548
+ return %5 : $@callee_guaranteed () -> (@owned A1, @error Error)
549
+ }
550
+
551
+ sil_vtable A3 {}
You can’t perform that action at this time.
0 commit comments