Skip to content

Commit 59b51b1

Browse files
committed
Fix crasher by mapping result type into context of func.
1 parent fbdd2b9 commit 59b51b1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/SILOptimizer/Mandatory/Differentiation.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3640,13 +3640,12 @@ class JVPEmitter final
36403640
assert(jvpResultArray.size() == 2 &&
36413641
"Result of JVP can only be 2 elements");
36423642
auto funcType = jvpResultArray[1].getType();
3643-
assert(funcType->is<SILFunctionType>() &&
3644-
"Second result must be a function");
36453643
auto silFuncCanType = funcType->castTo<SILFunctionType>()->getCanonicalType();
3646-
3647-
directResults.push_back(SILUndef::get(
3648-
SILType::getPrimitiveObjectType(silFuncCanType),
3649-
*jvp));
3644+
3645+
directResults.push_back(
3646+
SILUndef::get(jvp->mapTypeIntoContext(SILType::getPrimitiveObjectType(
3647+
silFuncCanType)),
3648+
*jvp));
36503649
builder.createReturn(
36513650
ri->getLoc(), joinElements(directResults, builder, loc));
36523651
}

0 commit comments

Comments
 (0)