swift
2d1f8256 - [Sema] [AutoDiff] Infer `@noDerivative` in `Differentiable` derived conformances and emit warning. (#22019)

Commit
6 years ago
[Sema] [AutoDiff] Infer `@noDerivative` in `Differentiable` derived conformances and emit warning. (#22019) * [Sema] [AutoDiff] Infer `@noDerivative` in `Differentiable` derived conformances and emit warning. * In `Differentiable` derived conformances, if a stored property is neither marked `@noDerivative` or conforming to `Differentiable`, the compiler would confusingly refuse to derive anything and fall back to the default "does not conform to protocol" errors. To better this user experience without losing predictability, we make the compiler imply `@noDerivative` (not having a corresponding field in `AllDifferentiableVariables`, `TangentVector` or `CotangentVector`) and emit a warning and a fixit so that the user will add a `@noDerivative` attribute. ```console var b: Bool ^ @noDerivative testsynthesis.swift:3:7: warning: stored property has no derivative because it does not conform to 'Differentiable'; add '@noDerivative' to make it explicit ``` * Add diagnostics for `@noDerivative` on stored type properties. * Add tests with stored type properties and verify that their existence will not affect `Differentiable` derived conformances.
Author
Parents
Loading