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

Side by Side Diff: test/checker/checker_test.dart

Issue 1092183003: Handle calls through call methods (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 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 | « lib/src/checker/rules.dart ('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) 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 /// General type checking tests 5 /// General type checking tests
6 library dev_compiler.test.checker_test; 6 library dev_compiler.test.checker_test;
7 7
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import 'package:dev_compiler/src/testing.dart'; 10 import 'package:dev_compiler/src/testing.dart';
11 11
12 import '../test_util.dart'; 12 import '../test_util.dart';
13 13
14 void main() { 14 void main() {
15 configureTest(); 15 configureTest();
16 16
17 test('dynamic invocation', () {
18 testChecker({
19 '/main.dart': '''
20
21 class A {
22 dynamic call(dynamic x) => x;
23 }
24 class B extends A {
25 int call(int x) => x;
26 double col(double x) => x;
27 }
28 void main() {
29 {
30 B f = new B();
31 int x;
32 double y;
33 // The analyzer has what I believe is a bug (dartbug.com/23252) which
34 // causes the return type of calls to f to be treated as dynamic.
35 x = /*info:DynamicCast should be pass*/f(3);
36 x = /*severe:StaticTypeError*/f.col(3.0);
37 y = /*info:DynamicCast should be severe:StaticTypeError*/f(3);
38 y = f.col(3.0);
39 f(/*severe:StaticTypeError*/3.0);
40 f.col(/*severe:StaticTypeError*/3);
41 }
42 {
43 Function f = new B();
44 int x;
45 double y;
46 x = /*info:DynamicCast, info:DynamicInvoke*/f(3);
47 x = /*info:DynamicCast, info:DynamicInvoke*/f.col(3.0);
48 y = /*info:DynamicCast, info:DynamicInvoke*/f(3);
49 y = /*info:DynamicCast, info:DynamicInvoke*/f.col(3.0);
50 (/*info:DynamicInvoke*/f(3.0));
51 (/*info:DynamicInvoke*/f.col(3));
52 }
53 {
54 A f = new B();
55 int x;
56 double y;
57 x = /*info:DynamicCast, info:DynamicInvoke*/f(3);
58 y = /*info:DynamicCast, info:DynamicInvoke*/f(3);
59 (/*info:DynamicInvoke*/f(3.0));
60 }
61 }
62 '''
63 });
64 });
65
17 test('conversion and dynamic invoke', () { 66 test('conversion and dynamic invoke', () {
18 testChecker({ 67 testChecker({
19 '/helper.dart': ''' 68 '/helper.dart': '''
20 dynamic toString = (int x) => x + 42; 69 dynamic toString = (int x) => x + 42;
21 dynamic hashCode = "hello"; 70 dynamic hashCode = "hello";
22 ''', 71 ''',
23 '/main.dart': ''' 72 '/main.dart': '''
24 import 'helper.dart' as helper; 73 import 'helper.dart' as helper;
25 74
26 class A { 75 class A {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 dynamic toString = () => null; 133 dynamic toString = () => null;
85 (/*info:DynamicInvoke*/toString()); 134 (/*info:DynamicInvoke*/toString());
86 135
87 (/*info:DynamicInvoke*/helper.toString()); 136 (/*info:DynamicInvoke*/helper.toString());
88 var toStringClosure2 = helper.toString; 137 var toStringClosure2 = helper.toString;
89 (/*info:DynamicInvoke*/toStringClosure2()); 138 (/*info:DynamicInvoke*/toStringClosure2());
90 int hashCode = /*info:DynamicCast*/helper.hashCode; 139 int hashCode = /*info:DynamicCast*/helper.hashCode;
91 140
92 baz().toString(); 141 baz().toString();
93 baz().hashCode; 142 baz().hashCode;
143 }
94 ''' 144 '''
95 }); 145 });
96 }); 146 });
97 147
98 test('Primitives', () { 148 test('Primitives', () {
99 testChecker({ 149 testChecker({
100 '/main.dart': ''' 150 '/main.dart': '''
101 int /*severe:InvalidVariableDeclaration*/a; 151 int /*severe:InvalidVariableDeclaration*/a;
102 double /*severe:InvalidVariableDeclaration*/b; 152 double /*severe:InvalidVariableDeclaration*/b;
103 num c; 153 num c;
(...skipping 2728 matching lines...) Expand 10 before | Expand all | Expand 10 after
2832 f = bar as II2D; 2882 f = bar as II2D;
2833 f = bar as DD2I; 2883 f = bar as DD2I;
2834 f = bar as DI2D; 2884 f = bar as DI2D;
2835 f = bar as ID2D; 2885 f = bar as ID2D;
2836 f = bar as DD2D; 2886 f = bar as DD2D;
2837 } 2887 }
2838 ''' 2888 '''
2839 }); 2889 });
2840 }); 2890 });
2841 } 2891 }
OLDNEW
« no previous file with comments | « lib/src/checker/rules.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698