@@ -3172,7 +3172,6 @@ intptr_t Class::ComputeNumTypeArguments() const {
31723172 // modified by finalization, only shifted to higher indices in the vector.
31733173 // The super type may not even be resolved yet. This is not necessary, since
31743174 // we only check for matching type parameters, which are resolved by default.
3175- const auto& type_params = TypeArguments::Handle(zone, type_parameters());
31763175 // Determine the maximum overlap of a prefix of the vector consisting of the
31773176 // type parameters of this class with a suffix of the vector consisting of the
31783177 // type arguments of the super type of this class.
@@ -3181,20 +3180,26 @@ intptr_t Class::ComputeNumTypeArguments() const {
31813180 // Attempt to overlap the whole vector of type parameters; reduce the size
31823181 // of the vector (keeping the first type parameter) until it fits or until
31833182 // its size is zero.
3184- auto& type_param = TypeParameter::Handle(zone);
31853183 auto& sup_type_arg = AbstractType::Handle(zone);
31863184 for (intptr_t num_overlapping_type_args =
31873185 (num_type_params < sup_type_args_length) ? num_type_params
31883186 : sup_type_args_length;
31893187 num_overlapping_type_args > 0; num_overlapping_type_args--) {
31903188 intptr_t i = 0;
31913189 for (; i < num_overlapping_type_args; i++) {
3192- type_param ^= type_params.TypeAt(i);
3193- ASSERT(!type_param.IsNull());
31943190 sup_type_arg = sup_type_args.TypeAt(sup_type_args_length -
31953191 num_overlapping_type_args + i);
31963192 ASSERT(!sup_type_arg.IsNull());
3197- if (!type_param.Equals(sup_type_arg)) break;
3193+ if (!sup_type_arg.IsTypeParameter()) break;
3194+ // The only type parameters appearing in the type arguments of the super
3195+ // type are those declared by this class. Their finalized indices depend
3196+ // on the number of type arguments being computed here. Therefore, they
3197+ // cannot possibly be finalized yet.
3198+ ASSERT(!TypeParameter::Cast(sup_type_arg).IsFinalized());
3199+ if (TypeParameter::Cast(sup_type_arg).index() != i ||
3200+ TypeParameter::Cast(sup_type_arg).IsNullable()) {
3201+ break;
3202+ }
31983203 }
31993204 if (i == num_overlapping_type_args) {
32003205 // Overlap found.
@@ -21033,12 +21038,12 @@ bool TypeParameter::IsEquivalent(const Instance& other,
2103321038 return false;
2103421039 }
2103521040 const TypeParameter& other_type_param = TypeParameter::Cast(other);
21041+ ASSERT(IsFinalized() && other_type_param.IsFinalized());
2103621042 // Compare index, name, bound, default argument, and flags.
2103721043 if (IsFunctionTypeParameter()) {
2103821044 if (!other_type_param.IsFunctionTypeParameter()) {
2103921045 return false;
2104021046 }
21041- ASSERT(IsFinalized() && other_type_param.IsFinalized());
2104221047 if (kind == TypeEquality::kInSubtypeTest) {
2104321048 // To be equivalent, the function type parameters should be declared
2104421049 // at the same position in the generic function. Their index therefore
@@ -21105,7 +21110,6 @@ bool TypeParameter::IsEquivalent(const Instance& other,
2110521110 return false;
2110621111 }
2110721112 } else {
21108- ASSERT(IsFinalized() && other_type_param.IsFinalized());
2110921113 if (index() != other_type_param.index()) {
2111021114 return false;
2111121115 }
0 commit comments