Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: runtime/vm/object.cc

Issue 1950133002: Fix cloning of generic function types when applying mixin members to mixin (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 16773 matching lines...) Expand 10 before | Expand all | Expand 10 after
16784 if (!clone.IsNull()) { 16784 if (!clone.IsNull()) {
16785 return clone.raw(); 16785 return clone.raw();
16786 } 16786 }
16787 const Class& type_cls = Class::Handle(zone, type_class()); 16787 const Class& type_cls = Class::Handle(zone, type_class());
16788 clone = Type::New(type_cls, TypeArguments::Handle(zone), token_pos()); 16788 clone = Type::New(type_cls, TypeArguments::Handle(zone), token_pos());
16789 // Preserve the bound error if any. 16789 // Preserve the bound error if any.
16790 if (IsMalbounded()) { 16790 if (IsMalbounded()) {
16791 const LanguageError& bound_error = LanguageError::Handle(zone, error()); 16791 const LanguageError& bound_error = LanguageError::Handle(zone, error());
16792 clone.set_error(bound_error); 16792 clone.set_error(bound_error);
16793 } 16793 }
16794 TypeArguments& type_args = TypeArguments::Handle(zone, arguments());
16795 bool type_args_cloned = false;
16794 // Clone the signature if this type represents a function type. 16796 // Clone the signature if this type represents a function type.
16795 const Function& fun = Function::Handle(zone, signature()); 16797 const Function& fun = Function::Handle(zone, signature());
16796 if (!fun.IsNull()) { 16798 if (!fun.IsNull()) {
16799 // If the scope class is not a typedef and if it is generic, it must be the
16800 // mixin class, set it to the new owner.
16801 if (!type_cls.IsTypedefClass() && type_cls.IsGeneric()) {
16802 clone.set_type_class(new_owner);
16803 AbstractType& decl_type = AbstractType::Handle(zone);
16804 #ifdef DEBUG
16805 decl_type = type_cls.DeclarationType();
16806 ASSERT(decl_type.IsFinalized());
16807 const TypeArguments& decl_type_args =
16808 TypeArguments::Handle(zone, decl_type.arguments());
16809 ASSERT(type_args.Equals(decl_type_args));
16810 #endif // DEBUG
16811 decl_type = new_owner.DeclarationType();
16812 ASSERT(decl_type.IsFinalized());
16813 type_args = decl_type.arguments();
16814 clone.set_arguments(type_args);
16815 type_args_cloned = true;
16816 }
16797 Function& fun_clone = Function::Handle(zone, 16817 Function& fun_clone = Function::Handle(zone,
16798 Function::NewSignatureFunction(new_owner, TokenPosition::kNoSource)); 16818 Function::NewSignatureFunction(new_owner, TokenPosition::kNoSource));
16799 AbstractType& type = AbstractType::Handle(zone, fun.result_type()); 16819 AbstractType& type = AbstractType::Handle(zone, fun.result_type());
16800 type = type.CloneUninstantiated(new_owner, trail); 16820 type = type.CloneUninstantiated(new_owner, trail);
16801 fun_clone.set_result_type(type); 16821 fun_clone.set_result_type(type);
16802 const intptr_t num_params = fun.NumParameters(); 16822 const intptr_t num_params = fun.NumParameters();
16803 fun_clone.set_num_fixed_parameters(fun.num_fixed_parameters()); 16823 fun_clone.set_num_fixed_parameters(fun.num_fixed_parameters());
16804 fun_clone.SetNumOptionalParameters(fun.NumOptionalParameters(), 16824 fun_clone.SetNumOptionalParameters(fun.NumOptionalParameters(),
16805 fun.HasOptionalPositionalParameters()); 16825 fun.HasOptionalPositionalParameters());
16806 fun_clone.set_parameter_types(Array::Handle(Array::New(num_params, 16826 fun_clone.set_parameter_types(Array::Handle(Array::New(num_params,
16807 Heap::kOld))); 16827 Heap::kOld)));
16808 for (intptr_t i = 0; i < num_params; i++) { 16828 for (intptr_t i = 0; i < num_params; i++) {
16809 type = fun.ParameterTypeAt(i); 16829 type = fun.ParameterTypeAt(i);
16810 type = type.CloneUninstantiated(new_owner, trail); 16830 type = type.CloneUninstantiated(new_owner, trail);
16811 fun_clone.SetParameterTypeAt(i, type); 16831 fun_clone.SetParameterTypeAt(i, type);
16812 } 16832 }
16813 fun_clone.set_parameter_names(Array::Handle(zone, fun.parameter_names())); 16833 fun_clone.set_parameter_names(Array::Handle(zone, fun.parameter_names()));
16814 clone.set_signature(fun_clone); 16834 clone.set_signature(fun_clone);
16815 } 16835 }
16816 TypeArguments& type_args = TypeArguments::Handle(zone, arguments()); 16836 if (!type_args_cloned) {
16817 // Upper bounds of uninstantiated type arguments may form a cycle. 16837 // Upper bounds of uninstantiated type arguments may form a cycle.
16818 if (type_args.IsRecursive() || !type_args.IsInstantiated()) { 16838 if (type_args.IsRecursive() || !type_args.IsInstantiated()) {
16819 AddOnlyBuddyToTrail(&trail, clone); 16839 AddOnlyBuddyToTrail(&trail, clone);
16840 }
16841 type_args = type_args.CloneUninstantiated(new_owner, trail);
16842 clone.set_arguments(type_args);
16820 } 16843 }
16821 type_args = type_args.CloneUninstantiated(new_owner, trail);
16822 clone.set_arguments(type_args);
16823 clone.SetIsFinalized(); 16844 clone.SetIsFinalized();
16824 return clone.raw(); 16845 return clone.raw();
16825 } 16846 }
16826 16847
16827 16848
16828 RawAbstractType* Type::Canonicalize(TrailPtr trail) const { 16849 RawAbstractType* Type::Canonicalize(TrailPtr trail) const {
16829 ASSERT(IsFinalized()); 16850 ASSERT(IsFinalized());
16830 if (IsCanonical() || IsMalformed()) { 16851 if (IsCanonical() || IsMalformed()) {
16831 ASSERT(IsMalformed() || TypeArguments::Handle(arguments()).IsOld()); 16852 ASSERT(IsMalformed() || TypeArguments::Handle(arguments()).IsOld());
16832 return this->raw(); 16853 return this->raw();
(...skipping 5570 matching lines...) Expand 10 before | Expand all | Expand 10 after
22403 return UserTag::null(); 22424 return UserTag::null();
22404 } 22425 }
22405 22426
22406 22427
22407 const char* UserTag::ToCString() const { 22428 const char* UserTag::ToCString() const {
22408 const String& tag_label = String::Handle(label()); 22429 const String& tag_label = String::Handle(label());
22409 return tag_label.ToCString(); 22430 return tag_label.ToCString();
22410 } 22431 }
22411 22432
22412 } // namespace dart 22433 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698