Skip to content

Commit 497b62d

Browse files
committed
[+0-all-args] PartialApply always takes parameters at +1. Use an ensurePlusOne to make sure we create a copy if we need to.
rdar://34222540
1 parent 7f25e57 commit 497b62d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/SILGen/SILGenPoly.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2915,7 +2915,7 @@ static ManagedValue createThunk(SILGenFunction &SGF,
29152915
SingleValueInstruction *thunkedFn =
29162916
SGF.B.createPartialApply(loc, thunkValue,
29172917
SILType::getPrimitiveObjectType(substFnType),
2918-
subs, fn.forward(SGF),
2918+
subs, fn.ensurePlusOne(SGF, loc).forward(SGF),
29192919
SILType::getPrimitiveObjectType(expectedType));
29202920
if (expectedType->isNoEscape()) {
29212921
thunkedFn = SGF.B.createConvertFunction(loc, thunkedFn,

test/SILGen/guaranteed_normal_args.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ struct Buffer {
2929

3030
typealias AnyObject = Builtin.AnyObject
3131

32+
protocol Protocol {
33+
associatedtype AssocType
34+
static func useInput(_ input: Builtin.Int32, into processInput: (AssocType) -> ())
35+
}
36+
3237
///////////
3338
// Tests //
3439
///////////
@@ -86,3 +91,11 @@ struct StructContainingBridgeObject {
8691
rawValue = Builtin.reinterpretCast(swiftObj)
8792
}
8893
}
94+
95+
struct ReabstractionThunkTest : Protocol {
96+
typealias AssocType = Builtin.Int32
97+
98+
static func useInput(_ input: Builtin.Int32, into processInput: (AssocType) -> ()) {
99+
processInput(input)
100+
}
101+
}

0 commit comments

Comments
 (0)