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

Side by Side Diff: pkg/analyzer/lib/src/generated/constant.dart

Issue 644283002: Type check field assignments during constant evaluation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | « no previous file | pkg/analyzer/lib/src/generated/error.dart » ('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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.constant; 8 library engine.constant;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 String superName = null; 768 String superName = null;
769 NodeList<Expression> superArguments = null; 769 NodeList<Expression> superArguments = null;
770 for (ConstructorInitializer initializer in initializers) { 770 for (ConstructorInitializer initializer in initializers) {
771 if (initializer is ConstructorFieldInitializer) { 771 if (initializer is ConstructorFieldInitializer) {
772 ConstructorFieldInitializer constructorFieldInitializer = initializer; 772 ConstructorFieldInitializer constructorFieldInitializer = initializer;
773 Expression initializerExpression = constructorFieldInitializer.expressio n; 773 Expression initializerExpression = constructorFieldInitializer.expressio n;
774 DartObjectImpl evaluationResult = initializerExpression.accept(initializ erVisitor); 774 DartObjectImpl evaluationResult = initializerExpression.accept(initializ erVisitor);
775 if (evaluationResult != null) { 775 if (evaluationResult != null) {
776 String fieldName = constructorFieldInitializer.fieldName.name; 776 String fieldName = constructorFieldInitializer.fieldName.name;
777 fieldMap[fieldName] = evaluationResult; 777 fieldMap[fieldName] = evaluationResult;
778 PropertyAccessorElement getter = definingClass.getGetter(fieldName);
Brian Wilkerson 2014/10/12 20:20:42 Seems like we should need to check for "getter !=
Paul Berry 2014/10/13 15:55:33 That's a good point. I'll add tests for these cas
779 PropertyInducingElement field = getter.variable;
780 if (!evaluationResult.isNull &&
781 !evaluationResult.type.isSubtypeOf(field.type)) {
782 errorReporter.reportErrorForNode(
783 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MIS MATCH,
784 node, [evaluationResult.type, fieldName, field.type]);
785 }
778 } 786 }
779 } else if (initializer is SuperConstructorInvocation) { 787 } else if (initializer is SuperConstructorInvocation) {
780 SuperConstructorInvocation superConstructorInvocation = initializer; 788 SuperConstructorInvocation superConstructorInvocation = initializer;
781 SimpleIdentifier name = superConstructorInvocation.constructorName; 789 SimpleIdentifier name = superConstructorInvocation.constructorName;
782 if (name != null) { 790 if (name != null) {
783 superName = name.name; 791 superName = name.name;
784 } 792 }
785 superArguments = superConstructorInvocation.argumentList.arguments; 793 superArguments = superConstructorInvocation.argumentList.arguments;
786 } 794 }
787 } 795 }
(...skipping 3846 matching lines...) Expand 10 before | Expand all | Expand 10 after
4634 4642
4635 @override 4643 @override
4636 String get typeName => "Type"; 4644 String get typeName => "Type";
4637 4645
4638 @override 4646 @override
4639 int get hashCode => _element == null ? 0 : _element.hashCode; 4647 int get hashCode => _element == null ? 0 : _element.hashCode;
4640 4648
4641 @override 4649 @override
4642 String toString() => _element == null ? "-unknown-" : _element.name; 4650 String toString() => _element == null ? "-unknown-" : _element.name;
4643 } 4651 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/error.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698