swift
a59e2a30 - Unique extended existential shapes using the generalized AST type.

Commit
3 years ago
Unique extended existential shapes using the generalized AST type. I wrote out this whole analysis of why different existential types might have the same logical content, and then I turned around and immediately uniqued existential shapes purely by logical content rather than the (generalized) formal type. Oh well. At least it's not too late to make ABI changes like this. We now store a reference to a mangling of the generalized formal type directly in the shape. This type alone is sufficient to unique the shape: - By the nature of the generalization algorithm, every type parameter in the generalization signature should be mentioned in the generalized formal type in a deterministic order. - By the nature of the generalization algorithm, every other requirement in the generalization signature should be implied by the positions in which generalization type parameters appear (e.g. because the formal type is C<T> & P, where C constrains its type parameter for well-formedness). - The requirement signature and type expression are extracted from the existential type. As a result, we no longer rely on computing a unique hash at compile time. Storing this separately from the requirement signature potentially allows runtimes with general shape support to work with future extensions to existential types even if they cannot demangle the generalized formal type. Storing the generalized formal type also allows us to easily and reliably extract the formal type of the existential. Otherwise, it's quite a heroic endeavor to match requirements back up with primary associated types. Doing so would also only allows us to extract *some* matching formal type, not necessarily the *right* formal type. So there's some good synergy here.
Author
Committer
Parents
Loading