OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 | 4 |
5 // TODO(jmesserly): this file needs to be refactored, it's a port from | 5 // TODO(jmesserly): this file needs to be refactored, it's a port from |
6 // package:dev_compiler's tests | 6 // package:dev_compiler's tests |
7 /// General type checking tests | 7 /// General type checking tests |
8 library analyzer.test.src.task.strong.checker_test; | 8 library analyzer.test.src.task.strong.checker_test; |
9 | 9 |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 95 } |
96 class B extends A { | 96 class B extends A { |
97 int call(int x) => x; | 97 int call(int x) => x; |
98 double col(double x) => x; | 98 double col(double x) => x; |
99 } | 99 } |
100 void main() { | 100 void main() { |
101 { | 101 { |
102 B f = new B(); | 102 B f = new B(); |
103 int x; | 103 int x; |
104 double y; | 104 double y; |
105 // The analyzer has what I believe is a bug (dartbug.com/23252) which | 105 x = f(3); |
106 // causes the return type of calls to f to be treated as dynamic. | |
107 x = /*info:DYNAMIC_CAST should be pass*/f(3); | |
108 x = /*severe:STATIC_TYPE_ERROR*/f.col(3.0); | 106 x = /*severe:STATIC_TYPE_ERROR*/f.col(3.0); |
109 y = /*info:DYNAMIC_CAST should be severe:STATIC_TYPE_ERROR*/f(3); | 107 y = /*severe:STATIC_TYPE_ERROR*/f(3); |
110 y = f.col(3.0); | 108 y = f.col(3.0); |
111 f(/*severe:STATIC_TYPE_ERROR*/3.0); | 109 f(/*severe:STATIC_TYPE_ERROR*/3.0); |
112 f.col(/*severe:STATIC_TYPE_ERROR*/3); | 110 f.col(/*severe:STATIC_TYPE_ERROR*/3); |
113 } | 111 } |
114 { | 112 { |
115 Function f = new B(); | 113 Function f = new B(); |
116 int x; | 114 int x; |
117 double y; | 115 double y; |
118 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3); | 116 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f(3); |
119 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f.col(3.0); | 117 x = /*info:DYNAMIC_CAST, info:DYNAMIC_INVOKE*/f.col(3.0); |
(...skipping 2349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2469 | 2467 |
2470 baz1() sync* { yield* (/*info:DYNAMIC_CAST*/x); } | 2468 baz1() sync* { yield* (/*info:DYNAMIC_CAST*/x); } |
2471 Iterable baz2() sync* { yield* (/*info:DYNAMIC_CAST*/x); } | 2469 Iterable baz2() sync* { yield* (/*info:DYNAMIC_CAST*/x); } |
2472 Iterable<int> baz3() sync* { yield* (/*warning:DOWN_CAST_COMPOSITE*/x);
} | 2470 Iterable<int> baz3() sync* { yield* (/*warning:DOWN_CAST_COMPOSITE*/x);
} |
2473 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } | 2471 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } |
2474 Iterable<int> baz5() sync* { yield* (/*info:INFERRED_TYPE_ALLOCATION*/ne
w Iterable()); } | 2472 Iterable<int> baz5() sync* { yield* (/*info:INFERRED_TYPE_ALLOCATION*/ne
w Iterable()); } |
2475 ''' | 2473 ''' |
2476 }); | 2474 }); |
2477 }); | 2475 }); |
2478 } | 2476 } |
OLD | NEW |