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

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

Issue 11369168: Fix result type checking of factory constructors of generic classes in VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « runtime/lib/string_base.dart ('k') | runtime/vm/parser.cc » ('j') | 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/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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 } else { 922 } else {
923 return parameterized_type.raw(); 923 return parameterized_type.raw();
924 } 924 }
925 } 925 }
926 926
927 927
928 void ClassFinalizer::ResolveAndFinalizeSignature(const Class& cls, 928 void ClassFinalizer::ResolveAndFinalizeSignature(const Class& cls,
929 const Function& function) { 929 const Function& function) {
930 // Resolve result type. 930 // Resolve result type.
931 AbstractType& type = AbstractType::Handle(function.result_type()); 931 AbstractType& type = AbstractType::Handle(function.result_type());
932 // TODO(regis): Remove this code once the parser checks the factory name and
933 // once the core library is fixed. See issue 6641.
932 // In case of a factory, the parser sets the factory result type to a type 934 // In case of a factory, the parser sets the factory result type to a type
933 // with an unresolved class whose name matches the factory name. 935 // with an unresolved class whose name matches the factory name and no type
936 // arguments. We resolve the class and specify type arguments in case the
937 // class is generic.
938 if (function.IsFactory()) {
939 Type& factory_result_type = Type::Handle();
940 factory_result_type ^= type.raw();
941 ASSERT(factory_result_type.arguments() == TypeArguments::null());
942 const UnresolvedClass& unresolved_factory_class =
943 UnresolvedClass::Handle(factory_result_type.unresolved_class());
944 const Class& factory_class =
945 Class::Handle(ResolveClass(cls, unresolved_factory_class));
946 if (factory_class.IsNull()) {
947 type = NewFinalizedMalformedType(
948 Error::Handle(), // No previous error.
949 cls,
950 unresolved_factory_class.token_pos(),
951 kTryResolve, // No compile-time error.
952 "cannot resolve factory class name '%s' from '%s'",
953 String::Handle(unresolved_factory_class.Name()).ToCString(),
954 String::Handle(cls.Name()).ToCString());
955 } else {
956 type = Type::New(factory_class,
957 TypeArguments::Handle(factory_class.type_parameters()),
958 unresolved_factory_class.token_pos());
959 }
960 }
934 // It is not a compile time error if this name does not resolve to a class or 961 // It is not a compile time error if this name does not resolve to a class or
935 // interface. 962 // interface.
936 ResolveType(cls, type, kCanonicalize); 963 ResolveType(cls, type, kCanonicalize);
937 type = FinalizeType(cls, type, kCanonicalize); 964 type = FinalizeType(cls, type, kCanonicalize);
938 // In production mode, a malformed result type is mapped to dynamic. 965 // In production mode, a malformed result type is mapped to dynamic.
939 if (!FLAG_enable_type_checks && type.IsMalformed()) { 966 if (!FLAG_enable_type_checks && type.IsMalformed()) {
940 type = Type::DynamicType(); 967 type = Type::DynamicType();
941 } 968 }
942 function.set_result_type(type); 969 function.set_result_type(type);
943 // Resolve formal parameter types. 970 // Resolve formal parameter types.
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 void ClassFinalizer::ReportError(const char* format, ...) { 1615 void ClassFinalizer::ReportError(const char* format, ...) {
1589 va_list args; 1616 va_list args;
1590 va_start(args, format); 1617 va_start(args, format);
1591 const Error& error = Error::Handle( 1618 const Error& error = Error::Handle(
1592 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); 1619 Parser::FormatError(Script::Handle(), -1, "Error", format, args));
1593 va_end(args); 1620 va_end(args);
1594 ReportError(error); 1621 ReportError(error);
1595 } 1622 }
1596 1623
1597 } // namespace dart 1624 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/string_base.dart ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698