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

Unified Diff: test/checker/checker_test.dart

Issue 1010893004: Allow S->T <: dynamic->T (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Add comment Created 5 years, 9 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: test/checker/checker_test.dart
diff --git a/test/checker/checker_test.dart b/test/checker/checker_test.dart
index 413677729e80aa426101d2250b4ff18986687b8e..f28a49a876a241d76e71f113116e3259bfaacb9d 100644
--- a/test/checker/checker_test.dart
+++ b/test/checker/checker_test.dart
@@ -19,6 +19,9 @@ void main() {
'/main.dart': '''
class A {
String x = "hello world";
+
+ void baz1(y) => x + y;
+ static baz2(y) => y + y;
}
void foo(String str) {
@@ -29,7 +32,32 @@ void main() {
foo(/*info:DownCast,warning:DynamicInvoke*/a.x);
}
- void main() => bar(new A());
+ typedef DynFun(x);
+ typedef StrFun(String x);
+
+ var bar1 = bar;
+
+ void main() {
+ var a = new A();
+ bar(a);
+ (/*warning:DynamicInvoke*/bar1(a));
+ var b = bar;
+ (/*warning:DynamicInvoke*/b(a));
+ var f1 = foo;
+ f1("hello");
+ dynamic f2 = foo;
+ (/*warning:DynamicInvoke*/f2("hello"));
+ DynFun f3 = foo;
+ (/*warning:DynamicInvoke*/f3("hello"));
+ (/*warning:DynamicInvoke*/f3(42));
+ StrFun f4 = foo;
+ f4("hello");
+ a.baz1("hello");
+ var b1 = a.baz1;
+ (/*warning:DynamicInvoke*/b1("hello"));
+ A.baz2("hello");
+ var b2 = A.baz2;
+ (/*warning:DynamicInvoke*/b2("hello"));
'''
});
});
@@ -457,15 +485,18 @@ void main() {
class A {}
- typedef dynamic Top(A x); // Top of the lattice
- typedef A Left(A x); // Left branch
- typedef dynamic Right(dynamic x); // Right branch
- typedef A Bot(dynamic x); // Bottom of the lattice
+ // Note: because we allow A->B <: dynamic->B, we have circularity
Leaf 2015/03/18 22:57:26 This comment is no longer true, I think?
vsm 2015/03/18 23:40:32 Removed
+ // in the subtyping here, and it's not a true lattice. In addition
+ // to the below, we also have Top <: Right.
+ typedef dynamic Left(A x); // Real left
Leaf 2015/03/18 22:57:26 Nit: Sorting Top -> Left, Right -> Bottom makes th
vsm 2015/03/18 23:40:32 Done.
+ typedef A Bottom(A x); // Real bottom
+ typedef dynamic Top(dynamic x); // Real top
+ typedef A Right(dynamic x); // Real right
- dynamic top(A x) => x;
- A left(A x) => x;
- dynamic right(dynamic x) => x;
- A bot(dynamic x) => /*info:DownCast*/x;
+ dynamic left(A x) => x;
+ A bot(A x) => x;
+ dynamic top(dynamic x) => x;
+ A right(dynamic x) => /*info:DownCast*/x;
void main() {
{
@@ -490,7 +521,7 @@ void main() {
f = bot;
}
{
- Bot f;
+ Bottom f;
f = /*warning:ClosureWrap*/top;
f = /*warning:ClosureWrap*/left;
f = /*warning:ClosureWrap*/right;
@@ -906,7 +937,7 @@ void main() {
D f3 = (x, y) => x + y;
Function f4 = (x, y) => x + y;
f2 = /*warning:ClosureWrap*/f1;
- f1 = /*warning:ClosureWrapLiteral*/(int x, int y) => x + y;
+ f1 = (int x, int y) => x + y;
f2 = /*severe:StaticTypeError*/(int x) => -x;
}
'''
@@ -1603,7 +1634,7 @@ void main() {
/*severe:InvalidMethodOverride*/A f1; // invalid for getter
/*severe:InvalidMethodOverride*/C f2; // invalid for setter
var f3;
- /*severe:InvalidMethodOverride*/dynamic f4;
+ /*severe:InvalidMethodOverride,severe:InvalidMethodOverride*/dynamic f4;
}
'''
}, inferFromOverrides: true);
@@ -1624,8 +1655,8 @@ void main() {
class Child extends Base {
/*severe:InvalidMethodOverride*/A f1; // invalid for getter
/*severe:InvalidMethodOverride*/C f2; // invalid for setter
- /*severe:InferableOverride*/var f3;
- /*severe:InvalidMethodOverride*/dynamic f4;
+ /*severe:InferableOverride,severe:InvalidMethodOverride*/var f3;
+ /*severe:InvalidMethodOverride,severe:InvalidMethodOverride*/dynamic f4;
}
'''
}, inferFromOverrides: false);
@@ -1719,8 +1750,8 @@ void main() {
class Child extends Base {
void set f1(A value) {}
/*severe:InvalidMethodOverride*/void set f2(C value) {}
- void set f3(value) {}
- void set f4(dynamic value) {}
+ /*severe:InvalidMethodOverride*/void set f3(value) {}
+ /*severe:InvalidMethodOverride*/void set f4(dynamic value) {}
set f5(B value) {}
}
'''
@@ -1751,8 +1782,8 @@ void main() {
void set f1(A value) {}
/*severe:InvalidMethodOverride*/void set f2(C value) {}
- void set f3(value) {}
- void set f4(dynamic value) {}
+ /*severe:InvalidMethodOverride*/void set f3(value) {}
+ /*severe:InvalidMethodOverride*/void set f4(dynamic value) {}
set f5(B value) {}
}
'''
@@ -1780,7 +1811,7 @@ void main() {
/*severe:InvalidMethodOverride*/C m2(C value) {}
/*severe:InvalidMethodOverride*/A m3(C value) {}
C m4(A value) {}
- m5(value) {}
+ /*severe:InvalidMethodOverride*/m5(value) {}
/*severe:InvalidMethodOverride*/dynamic m6(dynamic value) {}
}
'''
@@ -2214,14 +2245,14 @@ void main() {
implements I1 {}
class T2 extends Base implements I1 {
- m(a) {}
+ /*severe:InvalidMethodOverride,severe:InvalidMethodOverride*/m(a) {}
Leaf 2015/03/18 22:57:26 We may want to treat this differently long term.
vsm 2015/03/18 23:40:32 Agree. It seems as though we want the static type
}
class T3 extends Object with /*severe:InvalidMethodOverride*/Base
implements I1 {}
class T4 extends Object with Base implements I1 {
- m(a) {}
+ /*severe:InvalidMethodOverride,severe:InvalidMethodOverride*/m(a) {}
}
'''
});

Powered by Google App Engine
This is Rietveld 408576698