Skip to content

Commit 09516df

Browse files
aslclackary
authored andcommitted
[AutoDiff] Peel off @sendable implicit conversion when checking for unsupported differentiable function conversion (swiftlang#77869)
(cherry picked from commit 8e53ccd)
1 parent 8502c4a commit 09516df

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/Sema/CSApply.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6570,7 +6570,19 @@ maybeDiagnoseUnsupportedDifferentiableConversion(ConstraintSystem &cs,
65706570
maybeDiagnoseFunctionRef(unwrappedFnExpr);
65716571
return;
65726572
}
6573+
} else if (auto conv = dyn_cast<FunctionConversionExpr>(semanticExpr)) {
6574+
// Look through a function conversion that only adds or removes
6575+
// `@Sendable`.
6576+
auto ty1 = conv->getType()->castTo<AnyFunctionType>();
6577+
auto ty2 = conv->getSubExpr()->getType()->castTo<AnyFunctionType>();
6578+
6579+
if (ty1->withExtInfo(ty1->getExtInfo().withSendable(false))
6580+
->isEqual(ty2->withExtInfo(ty2->getExtInfo().withSendable(false)))) {
6581+
maybeDiagnoseFunctionRef(conv->getSubExpr()->getSemanticsProvidingExpr());
6582+
return;
6583+
}
65736584
}
6585+
65746586
ctx.Diags.diagnose(expr->getLoc(),
65756587
diag::invalid_differentiable_function_conversion_expr);
65766588
};

0 commit comments

Comments
 (0)