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

Unified Diff: pkg/analyzer/lib/src/task/strong/checker.dart

Issue 1948293003: Issue 25914. Fix for compound assignments like 'T += T'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
Index: pkg/analyzer/lib/src/task/strong/checker.dart
diff --git a/pkg/analyzer/lib/src/task/strong/checker.dart b/pkg/analyzer/lib/src/task/strong/checker.dart
index 3e6f6f52196978450f264947e8b879ab49b9179a..6b0049bf9bc941236254dd786cadd3158578e823 100644
--- a/pkg/analyzer/lib/src/task/strong/checker.dart
+++ b/pkg/analyzer/lib/src/task/strong/checker.dart
@@ -622,8 +622,8 @@ class CodeChecker extends RecursiveAstVisitor {
var staticInfo;
var rhsType = _getStaticType(expr.rightHandSide);
var lhsType = _getStaticType(expr.leftHandSide);
- var returnType = _specializedBinaryReturnType(
- op, lhsType, rhsType, functionType.returnType);
+ var returnType = rules.refineBinaryExpressionType(
+ typeProvider, lhsType, op, rhsType, functionType.returnType);
if (!rules.isSubtypeOf(returnType, lhsType)) {
final numType = typeProvider.numType;
@@ -921,32 +921,6 @@ class CodeChecker extends RecursiveAstVisitor {
CoercionInfo.set(info.node, info);
}
}
-
- DartType _specializedBinaryReturnType(
- TokenType op, DartType t1, DartType t2, DartType normalReturnType) {
- // This special cases binary return types as per 16.26 and 16.27 of the
- // Dart language spec.
- switch (op) {
- case TokenType.PLUS:
- case TokenType.MINUS:
- case TokenType.STAR:
- case TokenType.TILDE_SLASH:
- case TokenType.PERCENT:
- case TokenType.PLUS_EQ:
- case TokenType.MINUS_EQ:
- case TokenType.STAR_EQ:
- case TokenType.TILDE_SLASH_EQ:
- case TokenType.PERCENT_EQ:
- if (t1 == typeProvider.intType && t2 == typeProvider.intType) return t1;
- if (t1 == typeProvider.doubleType && t2 == typeProvider.doubleType)
- return t1;
- // This particular combo is not spelled out in the spec, but all
- // implementations and analyzer seem to follow this.
- if (t1 == typeProvider.doubleType && t2 == typeProvider.intType)
- return t1;
- }
- return normalReturnType;
- }
}
/// Checks for overriding declarations of fields and methods. This is used to
« no previous file with comments | « pkg/analyzer/lib/src/generated/type_system.dart ('k') | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698