Skip to content

Commit 191a85d

Browse files
Merge pull request #62857 from nate-chandler/opaque-values/1/20230104
[OpaqueValues] Map-into-context back-deploy thunk results.
2 parents 4a29080 + 921c6a0 commit 191a85d

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lib/SILGen/SILGenBackDeploy.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,16 @@ static void emitBackDeployForwardApplyAndReturnOrThrow(
133133

134134
// Emit error block.
135135
SGF.B.emitBlock(errorBB);
136-
SILValue error = errorBB->createPhiArgument(fnConv.getSILErrorType(TEC),
137-
OwnershipKind::Owned);
136+
SILValue error = errorBB->createPhiArgument(
137+
SGF.F.mapTypeIntoContext(fnConv.getSILErrorType(TEC)),
138+
OwnershipKind::Owned);
138139
SGF.B.createBranch(loc, SGF.ThrowDest.getBlock(), {error});
139140

140141
// Emit normal block.
141142
SGF.B.emitBlock(normalBB);
142-
SILValue result = normalBB->createPhiArgument(fnConv.getSILResultType(TEC),
143-
OwnershipKind::Owned);
143+
SILValue result = normalBB->createPhiArgument(
144+
SGF.F.mapTypeIntoContext(fnConv.getSILResultType(TEC)),
145+
OwnershipKind::Owned);
144146
SmallVector<SILValue, 4> directResults;
145147
extractAllElements(result, loc, SGF.B, directResults);
146148

test/SILGen/opaque_values_silgen.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,3 +636,12 @@ func takeKeyPathString<T>(_ kp: KeyPath<T, String>) {
636636
func giveKeyPathString() {
637637
takeKeyPathString(\StructWithAReadableStringProperty.s)
638638
}
639+
640+
// CHECK-LABEL: sil {{.*}}@$s20opaque_values_silgen29backDeployingReturningGenericyxxKlFTwb : {{.*}} <T> {{.*}} {
641+
// Ensure that there aren't any "normal" (in the sense of try_apply) blocks that
642+
// take unbound generic parameters (τ_0_0).
643+
// CHECK-NOT: {{bb[0-9]+}}({{%[^,]+}} : @owned $τ_0_0):
644+
// CHECK-LABEL: } // end sil function '$s20opaque_values_silgen29backDeployingReturningGenericyxxKlFTwb'
645+
@available(SwiftStdlib 5.1, *)
646+
@_backDeploy(before: SwiftStdlib 5.8)
647+
public func backDeployingReturningGeneric<T>(_ t: T) throws -> T { t }

0 commit comments

Comments
 (0)