Files
swift-mirror/test/AutoDiff/ModuleInterface/differentiation.swift
marcrasi eae4c5eece [AutoDiff upstream] @differentiable function type sema (#30648)
Add type checking for `@differentiable` function types:
- Check that parameters and results conform to `Differentiable`.
- Implicitly conform parameters and results whose types are generic parameters
  to `Differentiable`.
- Upstream most of the differentiable_func_type_type_checking.swift test from
  `tensorflow` branch. A few function conversion tests have not been added
   because they depend on the `@differentiable` function conversion pipeline.

Diagnose gracefully when the `Differentiable` protocol is unavailable because
`_Differentiation` has not been imported.

Resolves TF-823 and TF-1219.
2020-03-26 23:28:02 -07:00

14 lines
680 B
Swift

// RUN: %target-swift-frontend -typecheck -emit-module-interface-path %t.swiftinterface -enable-library-evolution -enable-experimental-differentiable-programming %s
// RUN: %FileCheck %s < %t.swiftinterface
import _Differentiation
public func a(f: @differentiable (Float) -> Float) {}
// CHECK: public func a(f: @differentiable (Swift.Float) -> Swift.Float)
public func b(f: @differentiable(linear) (Float) -> Float) {}
// CHECK: public func b(f: @differentiable(linear) (Swift.Float) -> Swift.Float)
public func c(f: @differentiable (Float, @noDerivative Float) -> Float) {}
// CHECK: public func c(f: @differentiable (Swift.Float, @noDerivative Swift.Float) -> Swift.Float)