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

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

Issue 2166133002: fix #26912, correct handling of op assign (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/static_type_analyzer.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 library analyzer.src.generated.error_verifier; 5 library analyzer.src.generated.error_verifier;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 4047 matching lines...) Expand 10 before | Expand all | Expand 10 after
4058 * that the given assignment is valid. The [lhs] is the left hand side 4058 * that the given assignment is valid. The [lhs] is the left hand side
4059 * expression. The [rhs] is the right hand side expression. 4059 * expression. The [rhs] is the right hand side expression.
4060 * 4060 *
4061 * See [StaticTypeWarningCode.INVALID_ASSIGNMENT]. 4061 * See [StaticTypeWarningCode.INVALID_ASSIGNMENT].
4062 */ 4062 */
4063 void _checkForInvalidCompoundAssignment( 4063 void _checkForInvalidCompoundAssignment(
4064 AssignmentExpression assignment, Expression lhs, Expression rhs) { 4064 AssignmentExpression assignment, Expression lhs, Expression rhs) {
4065 if (lhs == null) { 4065 if (lhs == null) {
4066 return; 4066 return;
4067 } 4067 }
4068 VariableElement leftVariableElement = getVariableElement(lhs); 4068 DartType leftType = getStaticType(lhs);
4069 DartType leftType = (leftVariableElement == null) 4069 DartType rightType = getStaticType(assignment);
4070 ? getStaticType(lhs)
4071 : leftVariableElement.type;
4072 MethodElement invokedMethod = assignment.staticElement;
4073 if (invokedMethod == null) {
4074 return;
4075 }
4076 DartType rightType = invokedMethod.type.returnType;
4077 if (leftType == null || rightType == null) {
4078 return;
4079 }
4080 if (!_typeSystem.isAssignableTo(rightType, leftType)) { 4070 if (!_typeSystem.isAssignableTo(rightType, leftType)) {
4081 _errorReporter.reportTypeErrorForNode( 4071 _errorReporter.reportTypeErrorForNode(
4082 StaticTypeWarningCode.INVALID_ASSIGNMENT, rhs, [rightType, leftType]); 4072 StaticTypeWarningCode.INVALID_ASSIGNMENT, rhs, [rightType, leftType]);
4083 } 4073 }
4084 } 4074 }
4085 4075
4086 /** 4076 /**
4087 * Check the given [initializer] to ensure that the field being initialized is 4077 * Check the given [initializer] to ensure that the field being initialized is
4088 * a valid field. The [fieldName] is the field name from the 4078 * a valid field. The [fieldName] is the field name from the
4089 * [ConstructorFieldInitializer]. The [staticElement] is the static element 4079 * [ConstructorFieldInitializer]. The [staticElement] is the static element
(...skipping 2370 matching lines...) Expand 10 before | Expand all | Expand 10 after
6460 class _InvocationCollector extends RecursiveAstVisitor { 6450 class _InvocationCollector extends RecursiveAstVisitor {
6461 final List<String> superCalls = <String>[]; 6451 final List<String> superCalls = <String>[];
6462 6452
6463 @override 6453 @override
6464 visitMethodInvocation(MethodInvocation node) { 6454 visitMethodInvocation(MethodInvocation node) {
6465 if (node.target is SuperExpression) { 6455 if (node.target is SuperExpression) {
6466 superCalls.add(node.methodName.name); 6456 superCalls.add(node.methodName.name);
6467 } 6457 }
6468 } 6458 }
6469 } 6459 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/static_type_analyzer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698