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

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

Issue 2271223004: fix #27110, mark implicit downcasts for op assign (Closed)
Patch Set: Created 4 years, 4 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/test/src/task/strong/checker_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/checker_test.dart b/pkg/analyzer/test/src/task/strong/checker_test.dart
index 4c2d8af7c6a7f850af83a4989fc4648593bb2ef0..a00747ebba441ed92752f8c0a3570ffc85012f0d 100644
--- a/pkg/analyzer/test/src/task/strong/checker_test.dart
+++ b/pkg/analyzer/test/src/task/strong/checker_test.dart
@@ -269,7 +269,7 @@ foo() => new A();
test() {
int x = 0;
x += 5;
- /*error:STATIC_TYPE_ERROR*/x += /*error:INVALID_ASSIGNMENT*/3.14;
Jennifer Messerly 2016/08/25 22:27:15 this is still detected as a sideways cast by _chec
+ x += /*error:INVALID_ASSIGNMENT*/3.14;
double y = 0.0;
y += 5;
@@ -280,12 +280,12 @@ test() {
z += 3.14;
x = /*info:DOWN_CAST_IMPLICIT*/x + z;
- x += /*info:DOWN_CAST_IMPLICIT*/z;
+ /*info:DOWN_CAST_IMPLICIT*/x += z;
Jennifer Messerly 2016/08/25 22:27:15 this is an example of where DDC would've been putt
y = y + z;
y += z;
dynamic w = 42;
- x += /*info:DYNAMIC_CAST*/w;
+ /*info:DOWN_CAST_IMPLICIT*/x += /*info:DYNAMIC_CAST*/w;
Jennifer Messerly 2016/08/25 22:27:15 here too. we need two casts. the first because "w"
y += /*info:DYNAMIC_CAST*/w;
z += /*info:DYNAMIC_CAST*/w;
@@ -301,7 +301,7 @@ test() {
a += b;
a += /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/a;
a -= b;
- /*error:STATIC_TYPE_ERROR*/b -= /*error:INVALID_ASSIGNMENT*/b;
Jennifer Messerly 2016/08/25 22:27:15 same reason here as to why this went away.
+ b -= /*error:INVALID_ASSIGNMENT*/b;
a <<= b;
a >>= b;
a &= b;
@@ -320,6 +320,20 @@ test() {
''');
}
+ void test_compoundAssignment_returnsDynamic() {
+ checkFile(r'''
+class Foo {
+ operator +(other) => null;
+}
+
+main() {
+ var foo = new Foo();
+ foo = /*info:DYNAMIC_CAST*/foo + 1;
+ /*info:DYNAMIC_CAST*/foo += 1;
Jennifer Messerly 2016/08/25 22:27:15 previously this line was an error, inconsistent wi
+}
+ ''');
+ }
+
void test_constructorInvalid() {
// Regression test for https://github.com/dart-lang/sdk/issues/26695
checkFile('''

Powered by Google App Engine
This is Rietveld 408576698