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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/compile_time_constants.dart

Issue 11412245: MalformedType used for all invalid type annotations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 8 years 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
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 part of dart2js; 5 part of dart2js;
6 6
7 /** 7 /**
8 * The [ConstantHandler] keeps track of compile-time constants, 8 * The [ConstantHandler] keeps track of compile-time constants,
9 * initializations of global and static fields, and default values of 9 * initializations of global and static fields, and default values of
10 * optional parameters. 10 * optional parameters.
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 value = new NullConstant(); 168 value = new NullConstant();
169 } else { 169 } else {
170 Node right = assignment.arguments.head; 170 Node right = assignment.arguments.head;
171 value = 171 value =
172 compileNodeWithDefinitions(right, definitions, isConst: isConst); 172 compileNodeWithDefinitions(right, definitions, isConst: isConst);
173 if (compiler.enableTypeAssertions 173 if (compiler.enableTypeAssertions
174 && value != null 174 && value != null
175 && element.isField()) { 175 && element.isField()) {
176 DartType elementType = element.computeType(compiler); 176 DartType elementType = element.computeType(compiler);
177 DartType constantType = value.computeType(compiler); 177 DartType constantType = value.computeType(compiler);
178 if (!constantSystem.isSubtype(compiler, constantType, elementType)) { 178 if (elementType.isMalformed || constantType.isMalformed ||
179 !constantSystem.isSubtype(compiler, constantType, elementType)) {
179 if (isConst) { 180 if (isConst) {
180 MessageKind kind = MessageKind.NOT_ASSIGNABLE; 181 MessageKind kind = MessageKind.NOT_ASSIGNABLE;
181 compiler.reportError(node, new CompileTimeConstantError( 182 compiler.reportError(node, new CompileTimeConstantError(
182 kind, [elementType, constantType])); 183 kind, [elementType, constantType]));
183 } else { 184 } else {
184 // If the field can be lazily initialized, we will throw 185 // If the field can be lazily initialized, we will throw
185 // the exception at runtime. 186 // the exception at runtime.
186 value = null; 187 value = null;
187 } 188 }
188 } 189 }
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 } 734 }
734 return super.visitSend(send); 735 return super.visitSend(send);
735 } 736 }
736 737
737 void potentiallyCheckType(Node node, Element element, Constant constant) { 738 void potentiallyCheckType(Node node, Element element, Constant constant) {
738 if (compiler.enableTypeAssertions) { 739 if (compiler.enableTypeAssertions) {
739 DartType elementType = element.computeType(compiler); 740 DartType elementType = element.computeType(compiler);
740 DartType constantType = constant.computeType(compiler); 741 DartType constantType = constant.computeType(compiler);
741 // TODO(ngeoffray): Handle type parameters. 742 // TODO(ngeoffray): Handle type parameters.
742 if (elementType.element.isTypeVariable()) return; 743 if (elementType.element.isTypeVariable()) return;
743 if (!constantSystem.isSubtype(compiler, constantType, elementType)) { 744 if (elementType.isMalformed || constantType.isMalformed ||
745 !constantSystem.isSubtype(compiler, constantType, elementType)) {
744 MessageKind kind = MessageKind.NOT_ASSIGNABLE; 746 MessageKind kind = MessageKind.NOT_ASSIGNABLE;
745 compiler.reportError(node, new CompileTimeConstantError( 747 compiler.reportError(node, new CompileTimeConstantError(
746 kind, [elementType, constantType])); 748 kind, [elementType, constantType]));
747 } 749 }
748 } 750 }
749 } 751 }
750 752
751 void updateFieldValue(Node node, Element element, Constant constant) { 753 void updateFieldValue(Node node, Element element, Constant constant) {
752 potentiallyCheckType(node, element, constant); 754 potentiallyCheckType(node, element, constant);
753 fieldValues[element] = constant; 755 fieldValues[element] = constant;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 // Use the default value. 875 // Use the default value.
874 fieldValue = handler.compileConstant(field); 876 fieldValue = handler.compileConstant(field);
875 } 877 }
876 jsNewArguments.add(fieldValue); 878 jsNewArguments.add(fieldValue);
877 }, 879 },
878 includeBackendMembers: true, 880 includeBackendMembers: true,
879 includeSuperMembers: true); 881 includeSuperMembers: true);
880 return jsNewArguments; 882 return jsNewArguments;
881 } 883 }
882 } 884 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698