Files
swift-mirror/test/AutoDiff/Sema
Tim Kientzle a0125d4657 Fix @derivative(of:) handling
This implements two approaches for specifying derivatives of
yielding mutate and borrow accessors:

1. Using backticks to specify a yielding accessor:
```
  // expected-note @+1 {{cannot register derivative for yielding borrow accessor}}
  var computedProperty2: T {
    yielding borrow { yield x }
    yielding mutate { yield &x }
  }

  // expected-error @+1 {{referenced declaration 'computedProperty2' could not be resolved}}
  @derivative(of: computedProperty2.`yielding borrow`)
  mutating func vjpPropertyYieldingBorrow(_ newValue: T) -> (
    value: (), pullback: (inout TangentVector) -> T.TangentVector
  ) { ...  }
```
This requires it to be spelled with exactly one space.

2. Use .borrow or .mutate and resolve in Sema:
```
  // expected-note @+1 {{cannot register derivative for yielding borrow accessor}}
  var computedProperty2: T {
    yielding borrow { yield x }
    yielding mutate { yield &x }
  }

  // expected-error @+1 {{referenced declaration 'computedProperty2' could not be resolved}}
  @derivative(of: computedProperty2.borrow)
  mutating func vjpPropertyYieldingBorrow(_ newValue: T) -> (
    value: (), pullback: (inout TangentVector) -> T.TangentVector
  ) { ...  }
```

In order to support the latter, I've had to refactor the
resolution for these names so that error messages can show
the type (e.g., "yielding borrow") of the actual resolved
accessor, even if that's different from the specification.
2026-01-05 16:42:08 -08:00
..