Yes, our use case is exactly "creating a SIL function with the derivative generic environment with additional requirements, and using the environment to remap types via TypeSubstCloner
machinery".
Thanks for this clarification, I’ve been wondering about this distinction. Generic environments have archetypes while generic signatures do not (only generic type parameter types and requirements).
Tentatively, we’ll pursue storing a derivative GenericSignature
in AST DifferentiableAttr
and SILDifferentiableAttr
then. Directly storing GenericSignature
will reduce code duplication and fix issues where derivative generic signature is currently computed incorrectly. Derivative SIL functions will have an (optional) generic environment created from this GenericSignature
, same as today.
Eventually, differentiability witness tables will replace SILDifferentiableAttr
and store an optional derivative GenericSignature
per entry.
Thanks again!