Chromium Code Reviews| Index: runtime/vm/class_finalizer.cc |
| diff --git a/runtime/vm/class_finalizer.cc b/runtime/vm/class_finalizer.cc |
| index f13d562061ef4a27dbfcfa430baea9bc8c33593c..e375fae50644b751828695cbe3df9080e785e6b5 100644 |
| --- a/runtime/vm/class_finalizer.cc |
| +++ b/runtime/vm/class_finalizer.cc |
| @@ -549,11 +549,24 @@ void ClassFinalizer::ResolveType(const Class& cls, const AbstractType& type) { |
| // Resolve signature if function type. |
| if (type.IsFunctionType()) { |
| const Function& signature = Function::Handle(Type::Cast(type).signature()); |
| - const Class& scope_class = Class::Handle(type.type_class()); |
| - if (scope_class.IsTypedefClass()) { |
| - ResolveSignature(scope_class, signature); |
| + Type& signature_type = Type::Handle(signature.SignatureType()); |
| + if (signature_type.raw() != type.raw()) { |
| + ResolveType(cls, signature_type); |
| } else { |
| - ResolveSignature(cls, signature); |
| + const Class& scope_class = Class::Handle(type.type_class()); |
| + if (scope_class.IsTypedefClass()) { |
| + ResolveSignature(scope_class, signature); |
| + } else { |
| + ResolveSignature(cls, signature); |
| + } |
| + if (signature.IsSignatureFunction()) { |
| + // Drop fields that are not necessary anymore after resolution. |
| + // TODO(regis): Setting the owner to null is breaking mirrors. |
| + // signature.set_owner(Object::Handle()); |
| + signature.set_parent_function(Function::Handle()); |
| + // TODO(regis): As long as we support metadata in typedef signatures, |
| + // we cannot reset the token position to TokenPosition::kNoSource. |
|
siva
2016/12/27 18:08:28
Is it necessary to drop the other fields? I can un
regis
2016/12/27 18:28:48
No, it is not necessary to drop them, but they are
|
| + } |
| } |
| } |
| } |
| @@ -2331,8 +2344,9 @@ void ClassFinalizer::FinalizeTypesInClass(const Class& cls) { |
| cls.set_mixin(mixin_type); |
| } |
| if (cls.IsTypedefClass()) { |
| - const Function& signature = Function::Handle(cls.signature_function()); |
| + Function& signature = Function::Handle(cls.signature_function()); |
| Type& type = Type::Handle(signature.SignatureType()); |
| + ASSERT(type.signature() == signature.raw()); |
| // Check for illegal self references. |
| GrowableArray<intptr_t> visited_aliases; |
| @@ -2350,7 +2364,12 @@ void ClassFinalizer::FinalizeTypesInClass(const Class& cls) { |
| // Resolve and finalize the signature type of this typedef. |
| type ^= FinalizeType(cls, type, kCanonicalizeWellFormed); |
| + |
| + // If a different canonical signature type is returned, update the signature |
| + // function of the typedef. |
| + signature = type.signature(); |
| signature.SetSignatureType(type); |
| + cls.set_signature_function(signature); |
| // Closure instances do not refer to this typedef as their class, so there |
| // is no need to add this typedef class to the subclasses of _Closure. |