Commit 6f4cf56
[mini_types] Add support for generic function types.
Generic function types have the following special behaviors:
- Their implementations of `hashCode` and `==` take care to ensure
that if two generic types differ only in the names of their type
parameters (i.e. they are alpha-equivalent), they will compare equal
and have the same hash code. For example, `T Function<T>()` and `U
Function<U>()` represent the same type. This logic takes advantage
of `Type.substitute` and `Type.gatherUsedIdentifiers`, added in
recent CLs.
- When parsing a generic function type, references to type formals can
appear in the return type or parameter types. E.g. in the function
type `T Function<T>()`, the return type `T` refers to the type
formal `T` declared by the function type. It doesn't refer to a `T`
declared elsewhere. To make this possible, the parameter
`typeFormalScope` has been added to `Type.materialize`; this carries
the meaning of type formals through the recursive process of
transforming a `_PreType` into a corresponding `Type`.
In a follow-up CL, I will use this new support to unit test the
generic function type logic that's recently been added to
`TypeConstraintGenerator` (see
https://dart-review.googlesource.com/c/sdk/+/393860).
Change-Id: Ib5e392f844990185b2602d22809eac5599505aff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395687
Reviewed-by: Chloe Stefantsova <[email protected]>
Commit-Queue: Paul Berry <[email protected]>1 parent e5274a5 commit 6f4cf56
File tree
2 files changed
+355
-69
lines changed2 files changed
+355
-69
lines changed
0 commit comments