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

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

Issue 2362563004: re-land fix #27110 with proper DDC side of changes (Closed)
Patch Set: add tests Created 4 years, 3 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 ae8ba3a29286512e5e7081e6664cb95531cfdfd0..ef9b1ebfec45429bd0a2d35d532b9fe90d0cdd20 100644
--- a/pkg/analyzer/test/src/task/strong/checker_test.dart
+++ b/pkg/analyzer/test/src/task/strong/checker_test.dart
@@ -265,12 +265,15 @@ class D {
D operator +(D d) => null;
}
+class SubA extends A {}
+class SubSubA extends SubA {}
+
foo() => new A();
test() {
int x = 0;
x += 5;
- /*error:STATIC_TYPE_ERROR*/x += /*error:INVALID_ASSIGNMENT*/3.14;
+ x += /*error:INVALID_ASSIGNMENT*/3.14;
double y = 0.0;
y += 5;
@@ -281,12 +284,12 @@ test() {
z += 3.14;
x = /*info:DOWN_CAST_IMPLICIT*/x + z;
- x += /*info:DOWN_CAST_IMPLICIT*/z;
+ /*info:DOWN_CAST_IMPLICIT_ASSIGN*/x += z;
y = y + z;
y += z;
dynamic w = 42;
- x += /*info:DYNAMIC_CAST*/w;
+ /*info:DOWN_CAST_IMPLICIT_ASSIGN*/x += /*info:DYNAMIC_CAST*/w;
y += /*info:DYNAMIC_CAST*/w;
z += /*info:DYNAMIC_CAST*/w;
@@ -302,7 +305,7 @@ test() {
a += b;
a += /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/a;
a -= b;
- /*error:STATIC_TYPE_ERROR*/b -= /*error:INVALID_ASSIGNMENT*/b;
+ b -= /*error:INVALID_ASSIGNMENT*/b;
a <<= b;
a >>= b;
a &= b;
@@ -310,6 +313,10 @@ test() {
a |= b;
/*info:DYNAMIC_INVOKE*/c += b;
+ SubA sa;
+ /*info:DOWN_CAST_IMPLICIT_ASSIGN*/sa += b;
+ SubSubA ssa = /*info:ASSIGNMENT_CAST,info:DOWN_CAST_IMPLICIT_ASSIGN*/sa += b;
+
var d = new D();
a[b] += d;
a[/*info:DYNAMIC_CAST*/c] += d;
@@ -373,6 +380,20 @@ main() {
''');
}
+ 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;
+}
+ ''');
+ }
+
void test_constructorInvalid() {
// Regression test for https://github.com/dart-lang/sdk/issues/26695
checkFile('''
@@ -3845,11 +3866,14 @@ class A {
A operator -(int x) => null;
A operator -() => null;
}
+class B extends A {}
+class C extends B {}
foo() => new A();
test() {
A a = new A();
+ B b = new B();
var c = foo();
dynamic d;
@@ -3871,6 +3895,17 @@ test() {
a--;
(/*info:DYNAMIC_INVOKE*/d++);
(/*info:DYNAMIC_INVOKE*/d--);
+
+ ++/*info:DOWN_CAST_IMPLICIT_ASSIGN*/b;
+ --/*info:DOWN_CAST_IMPLICIT_ASSIGN*/b;
+ /*info:DOWN_CAST_IMPLICIT_ASSIGN*/b++;
+ /*info:DOWN_CAST_IMPLICIT_ASSIGN*/b--;
+
+ takesC(C c) => null;
+ takesC(/*info:DOWN_CAST_IMPLICIT*/++/*info:DOWN_CAST_IMPLICIT_ASSIGN*/b);
+ takesC(/*info:DOWN_CAST_IMPLICIT*/--/*info:DOWN_CAST_IMPLICIT_ASSIGN*/b);
+ takesC(/*info:DOWN_CAST_IMPLICIT,info:DOWN_CAST_IMPLICIT_ASSIGN*/b++);
+ takesC(/*info:DOWN_CAST_IMPLICIT,info:DOWN_CAST_IMPLICIT_ASSIGN*/b--);
}''');
}
« no previous file with comments | « pkg/analyzer/lib/src/task/strong/checker.dart ('k') | pkg/analyzer/test/src/task/strong/non_null_checker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698