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

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

Issue 27420002: Throw a dynamic type error instead of a CastError in a type cast with a (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | 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/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 7485 matching lines...) Expand 10 before | Expand all | Expand 10 after
7496 ParseType(ClassFinalizer::kCanonicalize)); 7496 ParseType(ClassFinalizer::kCanonicalize));
7497 if (!type.IsInstantiated() && 7497 if (!type.IsInstantiated() &&
7498 (current_block_->scope->function_level() > 0)) { 7498 (current_block_->scope->function_level() > 0)) {
7499 // Make sure that the instantiator is captured. 7499 // Make sure that the instantiator is captured.
7500 CaptureInstantiator(); 7500 CaptureInstantiator();
7501 } 7501 }
7502 right_operand = new TypeNode(type_pos, type); 7502 right_operand = new TypeNode(type_pos, type);
7503 // The type is never malformed (mapped to dynamic), but it can be 7503 // The type is never malformed (mapped to dynamic), but it can be
7504 // malbounded in checked mode. 7504 // malbounded in checked mode.
7505 ASSERT(!type.IsMalformed()); 7505 ASSERT(!type.IsMalformed());
7506 if (((op_kind == Token::kIS) || (op_kind == Token::kISNOT)) && 7506 if (((op_kind == Token::kIS) || (op_kind == Token::kISNOT) ||
7507 (op_kind == Token::kAS)) &&
7507 type.IsMalbounded()) { 7508 type.IsMalbounded()) {
7508 // Note that a type error is thrown even if the tested value is null 7509 // Note that a type error is thrown even if the tested value is null
7509 // in a type test. However, no cast exception is thrown if the value 7510 // in a type test or in a type cast.
7510 // is null in a type cast.
7511 return ThrowTypeError(type_pos, type); 7511 return ThrowTypeError(type_pos, type);
7512 } 7512 }
7513 } 7513 }
7514 if (Token::IsRelationalOperator(op_kind) 7514 if (Token::IsRelationalOperator(op_kind)
7515 || Token::IsTypeTestOperator(op_kind) 7515 || Token::IsTypeTestOperator(op_kind)
7516 || Token::IsTypeCastOperator(op_kind) 7516 || Token::IsTypeCastOperator(op_kind)
7517 || Token::IsEqualityOperator(op_kind)) { 7517 || Token::IsEqualityOperator(op_kind)) {
7518 if (Token::IsTypeTestOperator(op_kind) || 7518 if (Token::IsTypeTestOperator(op_kind) ||
7519 Token::IsTypeCastOperator(op_kind)) { 7519 Token::IsTypeCastOperator(op_kind)) {
7520 if (!right_operand->AsTypeNode()->type().IsInstantiated()) { 7520 if (!right_operand->AsTypeNode()->type().IsInstantiated()) {
(...skipping 3105 matching lines...) Expand 10 before | Expand all | Expand 10 after
10626 void Parser::SkipQualIdent() { 10626 void Parser::SkipQualIdent() {
10627 ASSERT(IsIdentifier()); 10627 ASSERT(IsIdentifier());
10628 ConsumeToken(); 10628 ConsumeToken();
10629 if (CurrentToken() == Token::kPERIOD) { 10629 if (CurrentToken() == Token::kPERIOD) {
10630 ConsumeToken(); // Consume the kPERIOD token. 10630 ConsumeToken(); // Consume the kPERIOD token.
10631 ExpectIdentifier("identifier expected after '.'"); 10631 ExpectIdentifier("identifier expected after '.'");
10632 } 10632 }
10633 } 10633 }
10634 10634
10635 } // namespace dart 10635 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698