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

Side by Side Diff: tests/language/null_bottom_test.dart

Issue 2638183002: Issue 28027. Move Null to the bottom in the Analyzer. (Closed)
Patch Set: Fixes for review comments. Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « tests/language/language_analyzer2.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // Dart test for testing the ternary operator. 4 // Dart test for testing the ternary operator.
5 5
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8 // Test that `Null` acts like the bottom type - less than any other type. 8 // Test that `Null` acts like the bottom type - less than any other type.
9 9
10 bool isCheckedMode = () { bool c = false; assert(c = true); return c; } (); 10 bool isCheckedMode = () { bool c = false; assert(c = true); return c; } ();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 Expect.isTrue(((int _) => null) is Fun<int, Null>); 106 Expect.isTrue(((int _) => null) is Fun<int, Null>);
107 107
108 Null fun(int x) => null; 108 Null fun(int x) => null;
109 Fun<Null, int> fun2 = fun; // Safe assignment. 109 Fun<Null, int> fun2 = fun; // Safe assignment.
110 if (fun2 is Fun<int, Null>) { 110 if (fun2 is Fun<int, Null>) {
111 // If int->Null is *subtype* of Null->int (which it should be), 111 // If int->Null is *subtype* of Null->int (which it should be),
112 // then type promotion succeeds. 112 // then type promotion succeeds.
113 // If type promotion succeeds, the static type is int->Null, otherwise 113 // If type promotion succeeds, the static type is int->Null, otherwise
114 // it's Null->int. 114 // it's Null->int.
115 fun2(42); // Should not give a warning after type promotion. 115 fun2(42); // Should not give a warning after type promotion.
116 fun2(null).abs(); /// 03: static type warning, runtime error 116 fun2(null).abs(); /// 03: runtime error
117 } 117 }
118 } 118 }
119 119
120 class T1 { 120 class T1 {
121 Null foo(int x) => null; 121 Null foo(int x) => null;
122 int bar(Null x) => null; 122 int bar(Null x) => null;
123 Null baz(int x) => null; 123 Null baz(int x) => null;
124 int qux(Null x) => null; 124 int qux(Null x) => null;
125 } 125 }
126 126
127 class T2 extends T1 { 127 class T2 extends T1 {
128 Null foo(Null x) => null; /// 01: static type warning 128 Null foo(Null x) => null;
129 Null bar(Null x) => null; 129 Null bar(Null x) => null;
130 int baz(int x) => x; /// 02: static type warning 130 int baz(int x) => x;
131 int qux(int x) => x; 131 int qux(int x) => x;
132 } 132 }
133 133
134 // Avoid "variable not used" warnings. 134 // Avoid "variable not used" warnings.
135 use(x) { 135 use(x) {
136 return identical(x, x); 136 return identical(x, x);
137 } 137 }
OLDNEW
« no previous file with comments | « tests/language/language_analyzer2.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698