Skip to content

Commit

Permalink
[AutoDiff] Peel off @sendable implicit conversion when checking for
Browse files Browse the repository at this point in the history
unsupported differentiable function conversion
  • Loading branch information
asl committed Nov 29, 2024
1 parent c690fef commit 0c8afd3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/Sema/CSApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6550,7 +6550,19 @@ maybeDiagnoseUnsupportedDifferentiableConversion(ConstraintSystem &cs,
maybeDiagnoseFunctionRef(unwrappedFnExpr);
return;
}
} else if (auto conv = dyn_cast<FunctionConversionExpr>(semanticExpr)) {
// Look through a function conversion that only adds or removes
// `@Sendable`.
auto ty1 = conv->getType()->castTo<AnyFunctionType>();
auto ty2 = conv->getSubExpr()->getType()->castTo<AnyFunctionType>();

if (ty1->withExtInfo(ty1->getExtInfo().withSendable(false))
->isEqual(ty2->withExtInfo(ty2->getExtInfo().withSendable(false)))) {
maybeDiagnoseFunctionRef(conv->getSubExpr()->getSemanticsProvidingExpr());
return;
}
}

ctx.Diags.diagnose(expr->getLoc(),
diag::invalid_differentiable_function_conversion_expr);
};
Expand Down

0 comments on commit 0c8afd3

Please sign in to comment.