Index: runtime/vm/object.cc |
=================================================================== |
--- runtime/vm/object.cc (revision 20601) |
+++ runtime/vm/object.cc (working copy) |
@@ -9179,7 +9179,13 @@ |
num_type_params = 0; |
} |
} else { |
- first_type_param_index = num_args - num_type_params; |
+ // The actual type argument vector can be longer than necessary, because |
+ // of type optimizations. |
+ if (IsFinalized() && cls.is_finalized()) { |
+ first_type_param_index = cls.NumTypeArguments() - num_type_params; |
+ } else { |
+ first_type_param_index = num_args - num_type_params; |
+ } |
} |
if (cls.IsSignatureClass()) { |
// We may be reporting an error about a malformed function type. In that |
@@ -9192,8 +9198,10 @@ |
if (cls.IsCanonicalSignatureClass()) { |
const Function& signature_function = Function::Handle( |
cls.signature_function()); |
- // Signature classes have no super type. |
- ASSERT(first_type_param_index == 0); |
+ // Signature classes have no super type, however, they take as many |
+ // type arguments as the owner class of their signature function (if it |
+ // is non static and generic, see Class::NumTypeArguments()). Therefore, |
+ // first_type_param_index may be greater than 0 here. |
return signature_function.InstantiatedSignatureFrom(args, |
name_visibility); |
} |
@@ -9548,8 +9556,9 @@ |
AbstractTypeArguments::Handle(arguments()); |
type_arguments = type_arguments.InstantiateFrom(instantiator_type_arguments, |
malformed_error); |
+ // Note that the type class has to be resolved at this time, but not |
+ // necessarily finalized yet. We may be checking bounds at compile time. |
const Class& cls = Class::Handle(type_class()); |
- ASSERT(cls.is_finalized()); |
// This uninstantiated type is not modified, as it can be instantiated |
// with different instantiators. |
Type& instantiated_type = Type::Handle( |
@@ -9734,7 +9743,6 @@ |
bool TypeParameter::Equals(const Instance& other) const { |
- ASSERT(IsFinalized()); |
if (raw() == other.raw()) { |
return true; |
} |
@@ -9746,6 +9754,9 @@ |
if (parameterized_class() != other_type_param.parameterized_class()) { |
return false; |
} |
+ if (IsFinalized() != other_type_param.IsFinalized()) { |
+ return false; |
+ } |
if (index() != other_type_param.index()) { |
return false; |
} |