Skip to content

Commit fab1391

Browse files
authored
Merge pull request #17088 from gottesmm/swift-4.2-branch-radar40773543
[silgen] When transforming values into an existential box representat…
2 parents 7a35ad0 + 9a1d252 commit fab1391

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/SILGen/SILGenConvert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ ManagedValue SILGenFunction::emitExistentialErasure(
726726
ExistentialRepresentation::Boxed, *this);
727727
ManagedValue mv = F(SGFContext(&init));
728728
if (!mv.isInContext()) {
729-
mv.forwardInto(*this, loc, init.getAddress());
729+
mv.ensurePlusOne(*this, loc).forwardInto(*this, loc, init.getAddress());
730730
init.finishInitialization(*this);
731731
}
732732

test/SILGen/function_conversion.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,3 +641,27 @@ func rdar35702810_anyhashable() {
641641
// CHECK: convert_escape_to_noescape [not_guaranteed] [[PA]] : $@callee_guaranteed (@guaranteed Set<B>) -> () to $@noescape @callee_guaranteed (@guaranteed Set<B>) -> ()
642642
bar_set(type: B.self, fn_set)
643643
}
644+
645+
// ==== Function conversion with parameter substToOrig reabstraction.
646+
647+
struct FunctionConversionParameterSubstToOrigReabstractionTest {
648+
typealias SelfTy = FunctionConversionParameterSubstToOrigReabstractionTest
649+
650+
class Klass: Error {}
651+
652+
struct Foo<T> {
653+
static func enum1Func(_ : (T) -> Foo<Error>) -> Foo<Error> {
654+
// Just to make it compile.
655+
return Optional<Foo<Error>>.none!
656+
}
657+
}
658+
659+
static func bar<T>(t: T) -> Foo<T> {
660+
// Just to make it compile.
661+
return Optional<Foo<T>>.none!
662+
}
663+
664+
static func testFunc() -> Foo<Error> {
665+
return Foo<Klass>.enum1Func(SelfTy.bar)
666+
}
667+
}

0 commit comments

Comments
 (0)