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

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

Issue 649733002: Check field type when evaluating initializing formals. (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/element.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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 } 726 }
727 } 727 }
728 if (argumentValue != null) { 728 if (argumentValue != null) {
729 if (!argumentValue.isNull && !argumentValue.type.isSubtypeOf(parameter.t ype)) { 729 if (!argumentValue.isNull && !argumentValue.type.isSubtypeOf(parameter.t ype)) {
730 errorReporter.reportErrorForNode( 730 errorReporter.reportErrorForNode(
731 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMA TCH, 731 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMA TCH,
732 errorTarget, 732 errorTarget,
733 [argumentValue.type, parameter.type]); 733 [argumentValue.type, parameter.type]);
734 } 734 }
735 if (baseParameter.isInitializingFormal) { 735 if (baseParameter.isInitializingFormal) {
736 FieldElement field = (baseParameter as FieldFormalParameterElement).fi eld; 736 FieldElement field = (parameter as FieldFormalParameterElement).field;
737 if (field != null) { 737 if (field != null) {
738 DartType fieldType = field.type;
739 if (fieldType != parameter.type) {
740 // We've already checked that the argument can be assigned to the
741 // parameter; we also need to check that it can be assigned to
742 // the field.
743 if (!argumentValue.isNull &&
744 !argumentValue.type.isSubtypeOf(fieldType)) {
745 errorReporter.reportErrorForNode(
746 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE _MISMATCH,
747 errorTarget,
748 [argumentValue.type, fieldType]);
749 }
750 }
738 String fieldName = field.name; 751 String fieldName = field.name;
739 fieldMap[fieldName] = argumentValue; 752 fieldMap[fieldName] = argumentValue;
740 } 753 }
741 } else { 754 } else {
742 String name = baseParameter.name; 755 String name = baseParameter.name;
743 parameterMap[name] = argumentValue; 756 parameterMap[name] = argumentValue;
744 } 757 }
745 } 758 }
746 } 759 }
747 ConstantVisitor initializerVisitor = new ConstantVisitor.con2(typeProvider, parameterMap, errorReporter); 760 ConstantVisitor initializerVisitor = new ConstantVisitor.con2(typeProvider, parameterMap, errorReporter);
(...skipping 3866 matching lines...) Expand 10 before | Expand all | Expand 10 after
4614 4627
4615 @override 4628 @override
4616 String get typeName => "Type"; 4629 String get typeName => "Type";
4617 4630
4618 @override 4631 @override
4619 int get hashCode => _element == null ? 0 : _element.hashCode; 4632 int get hashCode => _element == null ? 0 : _element.hashCode;
4620 4633
4621 @override 4634 @override
4622 String toString() => _element == null ? "-unknown-" : _element.name; 4635 String toString() => _element == null ? "-unknown-" : _element.name;
4623 } 4636 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698