Skip to content

SILGen: Pseudogeneric partial applications do not produce pseudogeneric results. #17547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/SIL/SILBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ SILType SILBuilder::getPartialApplyResultType(SILType origTy, unsigned argCount,
auto params = FTI->getParameters();
auto newParams = params.slice(0, params.size() - argCount);

auto extInfo = FTI->getExtInfo().withRepresentation(
SILFunctionType::Representation::Thick);
auto extInfo = FTI->getExtInfo()
.withRepresentation(SILFunctionType::Representation::Thick)
.withIsPseudogeneric(false);

// If the original method has an @unowned_inner_pointer return, the partial
// application thunk will lifetime-extend 'self' for us, converting the
Expand Down
8 changes: 4 additions & 4 deletions lib/SILGen/SILGenBridging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc,
// escaped by storing a withoutActuallyEscaping closure in the block and after
// the block is ultimately destroyed checking that the closure is uniquely
// referenced.
bool useWithoutEscapingVerifcation = false;
bool useWithoutEscapingVerification = false;
ManagedValue escaping;
if (loweredFuncTy->isNoEscape()) {
auto escapingTy = loweredFuncTy->getWithExtInfo(
Expand All @@ -520,7 +520,7 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc,
funcType.withExtInfo(funcType->getExtInfo().withNoEscape(false));
funcType = escapingAnyTy;
fn = B.createCopyValue(loc, escaping);
useWithoutEscapingVerifcation = true;
useWithoutEscapingVerification = true;
}

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

// Form the block on the stack.
Expand All @@ -610,7 +610,7 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc,
// copy_block_without_escaping %block withoutEscaping %closure instruction.
// A mandatory SIL pass will replace this instruction by the required
// verification instruction sequence.
auto heapBlock = useWithoutEscapingVerifcation
auto heapBlock = useWithoutEscapingVerification
? SILValue(B.createCopyBlockWithoutEscaping(
loc, stackBlock, escaping.forward(*this)))
: SILValue(B.createCopyBlock(loc, stackBlock));
Expand Down
4 changes: 2 additions & 2 deletions test/Reflection/capture_descriptors.sil
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ bb0(%t: $T, %u: $U):
return %12 : $()
}

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

// CHECK: - Capture types:
Expand Down
7 changes: 7 additions & 0 deletions test/SILGen/Inputs/objc_block_to_func_to_block.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import Foundation;

@interface Foo<A>: NSObject

- (void)blockInception:(void (^ _Nonnull)(void (^ _Nonnull)(void (^ _Nonnull)(Foo<A> * _Nonnull))))b;

@end
8 changes: 8 additions & 0 deletions test/SILGen/objc_block_to_func_to_block.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// 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
// REQUIRES: objc_interop

import Foundation

func bar<A>(x: Foo<A>) {
x.blockInception { f in f { _ = $0 } }
}