mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This change separates out the formation of the generic signature and substitutions for a SIL substituted function type as a pre-pass before doing the actual function type lowering. The only input we really need to form this signature is the original abstraction pattern that a type is being lowered against, and pre-computing it should make the code less side-effecty and confusing. It also allows us to handle generic nominal types in a more robust way; we transfer over all of the nominal type requirements to the generalized generic signature, then when recursively visiting the bindings, we same-type-constrain the generic parameters used in those requirements to the newly-generalized generic arguments. This ensures that the minimized signature preserves any non-trivial requirements imposed by the nominal type, such as conditional conformances on its type arguments, same-type constraints among associated types, etc. This approach does lead to less-than-optimal generalized generic signatures getting generated, since nominal type generic arguments get same-type-bound either to other generic arguments or fixed to concrete types almost always. It would be useful to do a minimization pass on the final generic signature to eliminate these unnecessary generic arguments, but that can be done in a follow-up PR.
54 KiB
54 KiB