| OLD | NEW |
| 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/class_finalizer.h" | 5 #include "vm/class_finalizer.h" |
| 6 | 6 |
| 7 #include "vm/flags.h" | 7 #include "vm/flags.h" |
| 8 #include "vm/heap.h" | 8 #include "vm/heap.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/longjump.h" | 10 #include "vm/longjump.h" |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 ResolveInterfaces(type_class, &visited_interfaces); | 672 ResolveInterfaces(type_class, &visited_interfaces); |
| 673 FinalizeTypeParameters(type_class); | 673 FinalizeTypeParameters(type_class); |
| 674 } | 674 } |
| 675 | 675 |
| 676 // Finalize the current type arguments of the type, which are still the | 676 // Finalize the current type arguments of the type, which are still the |
| 677 // parsed type arguments. | 677 // parsed type arguments. |
| 678 AbstractTypeArguments& arguments = | 678 AbstractTypeArguments& arguments = |
| 679 AbstractTypeArguments::Handle(parameterized_type.arguments()); | 679 AbstractTypeArguments::Handle(parameterized_type.arguments()); |
| 680 if (!arguments.IsNull()) { | 680 if (!arguments.IsNull()) { |
| 681 intptr_t num_arguments = arguments.Length(); | 681 intptr_t num_arguments = arguments.Length(); |
| 682 AbstractType& type_argument = AbstractType::Handle(); |
| 682 for (intptr_t i = 0; i < num_arguments; i++) { | 683 for (intptr_t i = 0; i < num_arguments; i++) { |
| 683 AbstractType& type_argument = AbstractType::Handle(arguments.TypeAt(i)); | 684 type_argument = arguments.TypeAt(i); |
| 684 type_argument = FinalizeType(cls, type_argument, finalization); | 685 type_argument = FinalizeType(cls, type_argument, finalization); |
| 686 if (type_argument.IsMalformed()) { |
| 687 // In production mode, malformed type arguments are mapped to Dynamic. |
| 688 // In checked mode, a type with malformed type arguments is malformed. |
| 689 if (FLAG_enable_type_checks) { |
| 690 const Error& error = Error::Handle(type_argument.malformed_error()); |
| 691 const String& type_name = String::Handle(parameterized_type.Name()); |
| 692 FinalizeMalformedType(error, cls, parameterized_type, finalization, |
| 693 "type '%s' has malformed type argument", |
| 694 type_name.ToCString()); |
| 695 return parameterized_type.raw(); |
| 696 } else { |
| 697 type_argument = Type::DynamicType(); |
| 698 } |
| 699 } |
| 685 arguments.SetTypeAt(i, type_argument); | 700 arguments.SetTypeAt(i, type_argument); |
| 686 } | 701 } |
| 687 } | 702 } |
| 688 | 703 |
| 689 // The finalized type argument vector needs num_type_arguments types. | 704 // The finalized type argument vector needs num_type_arguments types. |
| 690 const intptr_t num_type_arguments = type_class.NumTypeArguments(); | 705 const intptr_t num_type_arguments = type_class.NumTypeArguments(); |
| 691 // The type class has num_type_parameters type parameters. | 706 // The type class has num_type_parameters type parameters. |
| 692 const intptr_t num_type_parameters = type_class.NumTypeParameters(); | 707 const intptr_t num_type_parameters = type_class.NumTypeParameters(); |
| 693 | 708 |
| 694 // Initialize the type argument vector. | 709 // Initialize the type argument vector. |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 void ClassFinalizer::ReportError(const char* format, ...) { | 1501 void ClassFinalizer::ReportError(const char* format, ...) { |
| 1487 va_list args; | 1502 va_list args; |
| 1488 va_start(args, format); | 1503 va_start(args, format); |
| 1489 const Error& error = Error::Handle( | 1504 const Error& error = Error::Handle( |
| 1490 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); | 1505 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); |
| 1491 va_end(args); | 1506 va_end(args); |
| 1492 ReportError(error); | 1507 ReportError(error); |
| 1493 } | 1508 } |
| 1494 | 1509 |
| 1495 } // namespace dart | 1510 } // namespace dart |
| OLD | NEW |