Skip to content

Commit b5c1502

Browse files
committed
SILGen: +1 function when converting for a reabstraction
1 parent eef57a5 commit b5c1502

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/SILGen/SILGenPoly.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3485,7 +3485,7 @@ ManagedValue Transform::transformFunction(ManagedValue fn,
34853485
// escaping->noescape conversion.
34863486
if (fnType != newFnType) {
34873487
SILType resTy = SILType::getPrimitiveObjectType(newFnType);
3488-
fn = SGF.B.createConvertFunction(Loc, fn, resTy);
3488+
fn = SGF.B.createConvertFunction(Loc, fn.ensurePlusOne(SGF, Loc), resTy);
34893489
}
34903490

34913491
// Now do thin-to-thick if necessary.

test/SILGen/function_conversion.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,3 +676,14 @@ func dontCrash() {
676676
let userInfo = ["hello": "world"]
677677
let d = [AnyHashable: Any](uniqueKeysWithValues: userInfo.map { ($0.key, $0.value) })
678678
}
679+
680+
struct Butt<T> {
681+
var foo: () throws -> T
682+
}
683+
684+
@_silgen_name("butt")
685+
func butt() -> Butt<Any>
686+
687+
func foo() throws -> Any {
688+
return try butt().foo()
689+
}

0 commit comments

Comments
 (0)