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

Unified Diff: pkg/analyzer/lib/src/generated/static_type_analyzer.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/error_verifier.dart ('k') | pkg/analyzer/lib/src/task/strong/checker.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/static_type_analyzer.dart
diff --git a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
index 103b2cbc1d82c5dbdf012c634ded0aba5ad5cb69..19019da8d839d5cceb3377b7a987e20d113c4021 100644
--- a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
+++ b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
@@ -258,13 +258,23 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
} else {
ExecutableElement staticMethodElement = node.staticElement;
DartType staticType = _computeStaticReturnType(staticMethodElement);
- staticType =
- _refineAssignmentExpressionType(node, staticType, _getStaticType);
+ staticType = _typeSystem.refineBinaryExpressionType(
+ _typeProvider,
+ node.leftHandSide.staticType,
+ operator,
+ node.rightHandSide.staticType,
+ staticType);
_recordStaticType(node, staticType);
MethodElement propagatedMethodElement = node.propagatedElement;
if (!identical(propagatedMethodElement, staticMethodElement)) {
DartType propagatedType =
_computeStaticReturnType(propagatedMethodElement);
+ propagatedType = _typeSystem.refineBinaryExpressionType(
+ _typeProvider,
+ node.leftHandSide.propagatedType,
+ operator,
+ node.rightHandSide.propagatedType,
+ propagatedType);
_resolver.recordPropagatedTypeIfBetter(node, propagatedType);
}
}
@@ -2232,44 +2242,6 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
}
/**
- * Attempts to make a better guess for the type of the given assignment
- * [expression], given that resolution has so far produced the [currentType].
- * The [typeAccessor] is used to access the corresponding type of the left
- * and right operands.
- */
- DartType _refineAssignmentExpressionType(AssignmentExpression expression,
- DartType currentType, DartType typeAccessor(Expression node)) {
- Expression leftHandSize = expression.leftHandSide;
- Expression rightHandSide = expression.rightHandSide;
- TokenType operator = expression.operator.type;
- DartType intType = _typeProvider.intType;
- if (typeAccessor(leftHandSize) == intType) {
- // int op= double
- if (operator == TokenType.MINUS_EQ ||
- operator == TokenType.PERCENT_EQ ||
- operator == TokenType.PLUS_EQ ||
- operator == TokenType.STAR_EQ) {
- DartType doubleType = _typeProvider.doubleType;
- if (typeAccessor(rightHandSide) == doubleType) {
- return doubleType;
- }
- }
- // int op= int
- if (operator == TokenType.MINUS_EQ ||
- operator == TokenType.PERCENT_EQ ||
- operator == TokenType.PLUS_EQ ||
- operator == TokenType.STAR_EQ ||
- operator == TokenType.TILDE_SLASH_EQ) {
- if (typeAccessor(rightHandSide) == intType) {
- return intType;
- }
- }
- }
- // default
- return currentType;
- }
-
- /**
* Create a table mapping HTML tag names to the names of the classes (in 'dart:html') that
* implement those tags.
*
« no previous file with comments | « pkg/analyzer/lib/src/generated/error_verifier.dart ('k') | pkg/analyzer/lib/src/task/strong/checker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698