Files
swift-mirror/test/AutoDiff/validation-test/existential.swift
Slava Pestov 4f6ba29715 AutoDiff: Disable requirement machine when building or testing Differentiation library
The SIL type lowering logic for AutoDiff gets the substituted generic signature
mixed up with the invocation generic signature, so it tries to ask questions
about DependentMemberTypes in a signature with no requirements. This triggers
assertions when the requirement machine is enabled.

Disable the requirement machine until this is fixed.
2021-07-30 19:42:31 -04:00

27 lines
609 B
Swift

// RUN: %target-run-simple-swift(-Xfrontend -requirement-machine=off)
// REQUIRES: executable_test
import StdlibUnittest
import DifferentiationUnittest
var ExistentialTests = TestSuite("Existential")
protocol A {
@differentiable(reverse, wrt: x)
func a(_ x: Tracked<Float>) -> Tracked<Float>
}
func b(g: A) -> Tracked<Float> {
return gradient(at: 3) { x in g.a(x) }
}
struct B : A {
@differentiable(reverse, wrt: x)
func a(_ x: Tracked<Float>) -> Tracked<Float> { return x * 5 }
}
ExistentialTests.testWithLeakChecking("Existential method VJP") {
expectEqual(5.0, b(g: B()))
}
runAllTests()