Skip to content

Commit 8e53ccd

Browse files
authored
[AutoDiff] Peel off @sendable implicit conversion when checking for unsupported differentiable function conversion (#77869)
1 parent 30cf647 commit 8e53ccd

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
@@ -6550,7 +6550,19 @@ maybeDiagnoseUnsupportedDifferentiableConversion(ConstraintSystem &cs,
65506550
maybeDiagnoseFunctionRef(unwrappedFnExpr);
65516551
return;
65526552
}
6553+
} else if (auto conv = dyn_cast<FunctionConversionExpr>(semanticExpr)) {
6554+
// Look through a function conversion that only adds or removes
6555+
// `@Sendable`.
6556+
auto ty1 = conv->getType()->castTo<AnyFunctionType>();
6557+
auto ty2 = conv->getSubExpr()->getType()->castTo<AnyFunctionType>();
6558+
6559+
if (ty1->withExtInfo(ty1->getExtInfo().withSendable(false))
6560+
->isEqual(ty2->withExtInfo(ty2->getExtInfo().withSendable(false)))) {
6561+
maybeDiagnoseFunctionRef(conv->getSubExpr()->getSemanticsProvidingExpr());
6562+
return;
6563+
}
65536564
}
6565+
65546566
ctx.Diags.diagnose(expr->getLoc(),
65556567
diag::invalid_differentiable_function_conversion_expr);
65566568
};

0 commit comments

Comments
 (0)