135443706b
Previously, vectors of type arguments were expanded to include type arguments corresponding to superclasses both in the instances of generic classes and in Type objects (after type finalization). As a result, Type objects after finalization could be recursive and need to use extra TypeRef objects to break loops. The finalization of types was very complex and sometimes slow. This change simplifies the representation of Type objects: now they always have short type argument vectors, corresponding only to the type parameters of their own classes (both before and after finalization). Vectors of type arguments in the instances of generic classes are still expanded/flattened. This greatly simplifies type finalization, makes Type objects non-recursive and removes the need to create and handle excessive TypeRefs for type arguments corresponding to superclasses, as those type arguments are no longer included into types. The only remaining use of TypeRefs is for bounds of type parameters. In order to expand/flatten type arguments, new methods Type::GetInstanceTypeArguments / Class::GetInstanceTypeArguments are introduced. They build canonical declaration type arguments once (for each class), and then instantiate them as needed. There are also simple helper methods to shrink type arguments (TypeArguments::FromInstanceTypeArguments) and expand type arguments without filling type arguments corresponding to superclasses (TypeArguments::ToInstantiatorTypeArguments). Time of edge case 'regress_51960_test' 15min -> 300ms. TEST=ci, runtime/tests/vm/dart/regress_51960_test.dart Fixes https://github.com/dart-lang/sdk/issues/52022 Fixes https://github.com/dart-lang/sdk/issues/51960 Change-Id: I75b466b74698a33c0bb5e1dcbd29542e413812a1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295060 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>