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

Unified Diff: pkg/analyzer/test/src/task/strong/inferred_type_test.dart

Issue 1957953004: Issue 26427. Refine type of 'T + int' and 'T + double' when 'T extends num'. (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
« no previous file with comments | « pkg/analyzer/lib/src/generated/type_system.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/strong/inferred_type_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
index 2465bfd65aae2d82459ec5b4cd27eb0a3afce15a..ae7c50d43ac41fa9675204b79289e1050d04ece4 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -3121,30 +3121,56 @@ final x = F;
expect(x.type.toString(), 'Type');
}
- void test_refineBinaryExpressionType_typeParameter() {
+ void test_refineBinaryExpressionType_typeParameter_T_double() {
checkFile('''
-class Point<T extends num> {
- T x;
- T y;
+class C<T extends num> {
+ T a;
- Point(this.x, this.y);
+ void op(double b) {
+ double r1 = a + b;
+ double r2 = a - b;
+ double r3 = a * b;
+ double r4 = a / b;
+ }
+}
+ ''');
+ }
- Point<T> operator +(Point<T> other) {
- return new Point<T>(x + other.x, y + other.y);
+ void test_refineBinaryExpressionType_typeParameter_T_int() {
+ checkFile('''
+class C<T extends num> {
+ T a;
+
+ void op(int b) {
+ T r1 = a + b;
+ T r2 = a - b;
+ T r3 = a * b;
}
- Point<T> operator -(Point<T> other) {
- return new Point<T>(x - other.x, y - other.y);
+ void opEq(int b) {
+ a += b;
+ a -= b;
+ a *= b;
+ }
+}
+ ''');
}
- Point<T> operator *(Point<T> other) {
- return new Point<T>(x * other.x, y * other.y);
+ void test_refineBinaryExpressionType_typeParameter_T_T() {
+ checkFile('''
+class C<T extends num> {
+ T a;
+
+ void op(T b) {
+ T r1 = a + b;
+ T r2 = a - b;
+ T r3 = a * b;
}
- void compoundAssignment(T k) {
- x += k;
- x -= k;
- x *= k;
+ void opEq(T b) {
+ a += b;
+ a -= b;
+ a *= b;
}
}
''');
« no previous file with comments | « pkg/analyzer/lib/src/generated/type_system.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698