Skip to content

Commit 1c60926

Browse files
authored
Merge pull request #17548 from jckarter/pseudogeneric-partial-apply-4.2
[4.2] SILGen: Pseudogeneric partial applications do not produce pseudogeneric results.
2 parents 6743f28 + a08da1b commit 1c60926

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
@@ -514,7 +514,7 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc,
514514
// escaped by storing a withoutActuallyEscaping closure in the block and after
515515
// the block is ultimately destroyed checking that the closure is uniquely
516516
// referenced.
517-
bool useWithoutEscapingVerifcation = false;
517+
bool useWithoutEscapingVerification = false;
518518
ManagedValue escaping;
519519
if (loweredFuncTy->isNoEscape()) {
520520
auto escapingTy = loweredFuncTy->getWithExtInfo(
@@ -527,7 +527,7 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc,
527527
funcType.withExtInfo(funcType->getExtInfo().withNoEscape(false));
528528
funcType = escapingAnyTy;
529529
fn = B.createCopyValue(loc, escaping);
530-
useWithoutEscapingVerifcation = true;
530+
useWithoutEscapingVerification = true;
531531
}
532532

533533
// Build the invoke function signature. The block will capture the original
@@ -597,7 +597,7 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc,
597597
// another reference for the is_escaping sentinel.
598598
buildFuncToBlockInvokeBody(thunkSGF, loc, funcType, blockType,
599599
loweredFuncTy, loweredBlockTy, storageTy,
600-
useWithoutEscapingVerifcation);
600+
useWithoutEscapingVerification);
601601
}
602602

603603
// Form the block on the stack.
@@ -617,7 +617,7 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc,
617617
// copy_block_without_escaping %block withoutEscaping %closure instruction.
618618
// A mandatory SIL pass will replace this instruction by the required
619619
// verification instruction sequence.
620-
auto heapBlock = useWithoutEscapingVerifcation
620+
auto heapBlock = useWithoutEscapingVerification
621621
? SILValue(B.createCopyBlockWithoutEscaping(
622622
loc, stackBlock, escaping.forward(*this)))
623623
: SILValue(B.createCopyBlock(loc, stackBlock));

test/Reflection/capture_descriptors.sil

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

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

220220
// 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)