Skip to content

Commit 7a7bb40

Browse files
authored
Merge pull request #17547 from jckarter/pseudogeneric-partial-apply
SILGen: Pseudogeneric partial applications do not produce pseudogeneric results.
2 parents 5459e0d + 55706bf commit 7a7bb40

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

lib/SIL/SILBuilder.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ SILType SILBuilder::getPartialApplyResultType(SILType origTy, unsigned argCount,
6262
auto params = FTI->getParameters();
6363
auto newParams = params.slice(0, params.size() - argCount);
6464

65-
auto extInfo = FTI->getExtInfo().withRepresentation(
66-
SILFunctionType::Representation::Thick);
65+
auto extInfo = FTI->getExtInfo()
66+
.withRepresentation(SILFunctionType::Representation::Thick)
67+
.withIsPseudogeneric(false);
6768

6869
// If the original method has an @unowned_inner_pointer return, the partial
6970
// application thunk will lifetime-extend 'self' for us, converting the

lib/SILGen/SILGenBridging.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc,
507507
// escaped by storing a withoutActuallyEscaping closure in the block and after
508508
// the block is ultimately destroyed checking that the closure is uniquely
509509
// referenced.
510-
bool useWithoutEscapingVerifcation = false;
510+
bool useWithoutEscapingVerification = false;
511511
ManagedValue escaping;
512512
if (loweredFuncTy->isNoEscape()) {
513513
auto escapingTy = loweredFuncTy->getWithExtInfo(
@@ -520,7 +520,7 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc,
520520
funcType.withExtInfo(funcType->getExtInfo().withNoEscape(false));
521521
funcType = escapingAnyTy;
522522
fn = B.createCopyValue(loc, escaping);
523-
useWithoutEscapingVerifcation = true;
523+
useWithoutEscapingVerification = true;
524524
}
525525

526526
// Build the invoke function signature. The block will capture the original
@@ -590,7 +590,7 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc,
590590
// another reference for the is_escaping sentinel.
591591
buildFuncToBlockInvokeBody(thunkSGF, loc, funcType, blockType,
592592
loweredFuncTy, loweredBlockTy, storageTy,
593-
useWithoutEscapingVerifcation);
593+
useWithoutEscapingVerification);
594594
}
595595

596596
// Form the block on the stack.
@@ -610,7 +610,7 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc,
610610
// copy_block_without_escaping %block withoutEscaping %closure instruction.
611611
// A mandatory SIL pass will replace this instruction by the required
612612
// verification instruction sequence.
613-
auto heapBlock = useWithoutEscapingVerifcation
613+
auto heapBlock = useWithoutEscapingVerification
614614
? SILValue(B.createCopyBlockWithoutEscaping(
615615
loc, stackBlock, escaping.forward(*this)))
616616
: SILValue(B.createCopyBlock(loc, stackBlock));

test/Reflection/capture_descriptors.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ bb0(%t: $T, %u: $U):
208208
return %12 : $()
209209
}
210210

211-
sil @pseudogeneric_caller : $@convention(thin) @pseudogeneric <A : AnyObject, B : AnyObject, C : AnyObject> (@owned A, @owned B) -> @owned @pseudogeneric @callee_guaranteed () -> () {
211+
sil @pseudogeneric_caller : $@convention(thin) @pseudogeneric <A : AnyObject, B : AnyObject, C : AnyObject> (@owned A, @owned B) -> @owned @callee_guaranteed () -> () {
212212
bb0(%a: $A, %b: $B):
213213
%f = function_ref @pseudogeneric_callee : $@convention(thin) @pseudogeneric <T : AnyObject, U : AnyObject> (@owned T, @owned U) -> ()
214214
%c = partial_apply [callee_guaranteed] %f<A, B>(%a, %b) : $@convention(thin) @pseudogeneric <A : AnyObject, B : AnyObject> (@owned A, @owned B) -> ()
215-
return %c : $@pseudogeneric @callee_guaranteed () -> ()
215+
return %c : $@callee_guaranteed () -> ()
216216
}
217217

218218
// CHECK: - Capture types:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@import Foundation;
2+
3+
@interface Foo<A>: NSObject
4+
5+
- (void)blockInception:(void (^ _Nonnull)(void (^ _Nonnull)(void (^ _Nonnull)(Foo<A> * _Nonnull))))b;
6+
7+
@end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -import-objc-header %S/Inputs/objc_block_to_func_to_block.h -emit-silgen -verify %s
2+
// REQUIRES: objc_interop
3+
4+
import Foundation
5+
6+
func bar<A>(x: Foo<A>) {
7+
x.blockInception { f in f { _ = $0 } }
8+
}

0 commit comments

Comments
 (0)