mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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.
27 lines
609 B
Swift
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()
|