[AutoDiff] Simplify conditions enabling differentiable programming. (#30765)

Previously, two conditions were necessary to enable differentiable programming:
- Using the `-enable-experimental-differentiable-programming` frontend flag.
- Importing the `_Differentiation` module.

Importing the `_Differentiation` module is the true condition because it
contains the required compiler-known `Differentiable` protocol. The frontend
flag is redundant and cumbersome.

Now, the frontend flag is removed.
Importing `_Differentiation` is the only condition.
This commit is contained in:
Dan Zheng
2020-04-02 03:24:03 -07:00
committed by GitHub
parent e94f01d7e6
commit 1308fc69c5
43 changed files with 133 additions and 106 deletions

View File

@@ -56,9 +56,9 @@ static StringRef getMathOperatorName(MathOperator op) {
bool DerivedConformance::canDeriveAdditiveArithmetic(NominalTypeDecl *nominal,
DeclContext *DC) {
// Experimental `AdditiveArithmetic` derivation must be enabled.
auto &ctx = nominal->getASTContext();
if (!ctx.LangOpts.EnableExperimentalAdditiveArithmeticDerivedConformances)
return false;
if (auto *SF = DC->getParentSourceFile())
if (!isAdditiveArithmeticConformanceDerivationEnabled(*SF))
return false;
// Nominal type must be a struct. (No stored properties is okay.)
auto *structDecl = dyn_cast<StructDecl>(nominal);
if (!structDecl)