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

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

Issue 2210293002: infer null from context, this avoids bottom being introduced (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
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/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 741659a2822bad3484d6af9030708eb1b282277d..b4d73c8ec76c5cdf5df5e607cc2e8d122dd9adb7 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -451,14 +451,13 @@ var f = /*info:INFERRED_TYPE_CLOSURE,warning:UNSAFE_BLOCK_CLOSURE_INFERENCE*/()
void test_bottom() {
// When a type is inferred from the expression `null`, the inferred type is
- // `dynamic`, but the inferred type of the initializer is `bottom`.
- // TODO(paulberry): Is this intentional/desirable?
+ // `dynamic`.
var mainUnit = checkFile('''
var v = null;
''');
var v = mainUnit.topLevelVariables[0];
expect(v.type.toString(), 'dynamic');
- expect(v.initializer.type.toString(), '() → <bottom>');
+ expect(v.initializer.type.toString(), '() → dynamic');
}
void test_bottom_inClosure() {
@@ -1011,7 +1010,7 @@ typedef T Function2<S, T>(S x);
void main () {
{
- Function2<int, String> l0 = /*info:INFERRED_TYPE_CLOSURE*/(int x) => null;
+ Function2<int, String> l0 = (int x) => null;
Function2<int, String> l1 = (int x) => "hello";
Function2<int, String> l2 = /*error:INVALID_ASSIGNMENT*/(String x) => "hello";
Function2<int, String> l3 = /*error:INVALID_ASSIGNMENT*/(int x) => 3;
@@ -1025,7 +1024,7 @@ void main () {
Function2<int, String> l4 = /*info:INFERRED_TYPE_CLOSURE*/(x) {return /*error:RETURN_OF_INVALID_TYPE*/x;};
}
{
- Function2<int, List<String>> l0 = /*info:INFERRED_TYPE_CLOSURE*/(int x) => null;
+ Function2<int, List<String>> l0 = (int x) => null;
Function2<int, List<String>> l1 = (int x) => /*info:INFERRED_TYPE_LITERAL*/["hello"];
Function2<int, List<String>> l2 = /*error:INVALID_ASSIGNMENT*/(String x) => /*info:INFERRED_TYPE_LITERAL*/["hello"];
Function2<int, List<String>> l3 = (int x) => /*info:INFERRED_TYPE_LITERAL*/[/*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/3];
@@ -1131,7 +1130,7 @@ void main () {
{
String f/*<S>*/(int x) => null;
var v = f;
- v = /*info:INFERRED_TYPE_CLOSURE*//*<T>*/(int x) => null;
+ v = /*<T>*/(int x) => null;
v = /*<T>*/(int x) => "hello";
v = /*error:INVALID_ASSIGNMENT*//*<T>*/(String x) => "hello";
v = /*error:INVALID_ASSIGNMENT*//*<T>*/(int x) => 3;
@@ -1140,7 +1139,7 @@ void main () {
{
String f/*<S>*/(int x) => null;
var v = f;
- v = /*info:INFERRED_TYPE_CLOSURE, info:INFERRED_TYPE_CLOSURE*//*<T>*/(x) => null;
+ v = /*info:INFERRED_TYPE_CLOSURE*//*<T>*/(x) => null;
v = /*info:INFERRED_TYPE_CLOSURE*//*<T>*/(x) => "hello";
v = /*info:INFERRED_TYPE_CLOSURE, error:INVALID_ASSIGNMENT*//*<T>*/(x) => 3;
v = /*info:INFERRED_TYPE_CLOSURE, info:INFERRED_TYPE_CLOSURE*//*<T>*/(x) {return /*error:RETURN_OF_INVALID_TYPE*/3;};
@@ -1149,7 +1148,7 @@ void main () {
{
List<String> f/*<S>*/(int x) => null;
var v = f;
- v = /*info:INFERRED_TYPE_CLOSURE*//*<T>*/(int x) => null;
+ v = /*<T>*/(int x) => null;
v = /*<T>*/(int x) => /*info:INFERRED_TYPE_LITERAL*/["hello"];
v = /*error:INVALID_ASSIGNMENT*//*<T>*/(String x) => /*info:INFERRED_TYPE_LITERAL*/["hello"];
v = /*<T>*/(int x) => /*info:INFERRED_TYPE_LITERAL*/[/*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/3];
@@ -2806,7 +2805,8 @@ class C {
num n;
}
C f() => null;
-var x = (f().n *= null);
+var x = (f().n *= (null as num));
+var y = (f().n *= /*error:STATIC_TYPE_ERROR*/null);
''');
var x = mainUnit.topLevelVariables[0];
expect(x.name, 'x');
@@ -2819,7 +2819,8 @@ class C {
num n;
}
C c;
-var x = (c.n *= null);
+var x = (c.n *= (null as num));
+var y = (c.n *= /*error:STATIC_TYPE_ERROR*/null);
Leaf 2016/08/04 23:52:55 This doesn't seem right either.
Jennifer Messerly 2016/08/05 13:46:36 yeah, this one could be fixed in a straightforward
''');
var x = mainUnit.topLevelVariables[1];
expect(x.name, 'x');
@@ -2833,7 +2834,7 @@ class I {
}
abstract class C implements I {}
C c;
-var x = (c.n *= null);
+var x = (c.n *= (null as num));
''');
var x = mainUnit.topLevelVariables[1];
expect(x.name, 'x');
@@ -2847,7 +2848,7 @@ class I {
}
abstract class C implements I {}
C f() => null;
-var x = (f().n *= null);
+var x = (f().n *= (null as num));
''');
var x = mainUnit.topLevelVariables[0];
expect(x.name, 'x');

Powered by Google App Engine
This is Rietveld 408576698