Chromium Code Reviews| 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 library analyzer.test.src.task.strong.checker_test; | 5 library analyzer.test.src.task.strong.checker_test; |
| 6 | 6 |
| 7 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 7 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 8 | 8 |
| 9 import 'strong_test_helper.dart'; | 9 import 'strong_test_helper.dart'; |
| 10 | 10 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 | 263 |
| 264 class D { | 264 class D { |
| 265 D operator +(D d) => null; | 265 D operator +(D d) => null; |
| 266 } | 266 } |
| 267 | 267 |
| 268 foo() => new A(); | 268 foo() => new A(); |
| 269 | 269 |
| 270 test() { | 270 test() { |
| 271 int x = 0; | 271 int x = 0; |
| 272 x += 5; | 272 x += 5; |
| 273 /*error:STATIC_TYPE_ERROR*/x += /*error:INVALID_ASSIGNMENT*/3.14; | 273 x += /*error:INVALID_ASSIGNMENT*/3.14; |
| 274 | 274 |
| 275 double y = 0.0; | 275 double y = 0.0; |
| 276 y += 5; | 276 y += 5; |
| 277 y += 3.14; | 277 y += 3.14; |
| 278 | 278 |
| 279 num z = 0; | 279 num z = 0; |
| 280 z += 5; | 280 z += 5; |
| 281 z += 3.14; | 281 z += 3.14; |
| 282 | 282 |
| 283 x = /*info:DOWN_CAST_IMPLICIT*/x + z; | 283 x = /*info:DOWN_CAST_IMPLICIT*/x + z; |
| 284 x += /*info:DOWN_CAST_IMPLICIT*/z; | 284 /*info:DOWN_CAST_IMPLICIT_ASSIGN*/x += z; |
| 285 y = y + z; | 285 y = y + z; |
| 286 y += z; | 286 y += z; |
| 287 | 287 |
| 288 dynamic w = 42; | 288 dynamic w = 42; |
| 289 x += /*info:DYNAMIC_CAST*/w; | 289 /*info:DOWN_CAST_IMPLICIT_ASSIGN*/x += /*info:DYNAMIC_CAST*/w; |
| 290 y += /*info:DYNAMIC_CAST*/w; | 290 y += /*info:DYNAMIC_CAST*/w; |
| 291 z += /*info:DYNAMIC_CAST*/w; | 291 z += /*info:DYNAMIC_CAST*/w; |
| 292 | 292 |
| 293 A a = new A(); | 293 A a = new A(); |
| 294 B b = new B(); | 294 B b = new B(); |
| 295 var c = foo(); | 295 var c = foo(); |
| 296 a = a * b; | 296 a = a * b; |
| 297 a *= b; | 297 a *= b; |
| 298 a *= /*info:DYNAMIC_CAST*/c; | 298 a *= /*info:DYNAMIC_CAST*/c; |
| 299 a /= b; | 299 a /= b; |
| 300 a ~/= b; | 300 a ~/= b; |
| 301 a %= b; | 301 a %= b; |
| 302 a += b; | 302 a += b; |
| 303 a += /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/a; | 303 a += /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/a; |
| 304 a -= b; | 304 a -= b; |
| 305 /*error:STATIC_TYPE_ERROR*/b -= /*error:INVALID_ASSIGNMENT*/b; | 305 b -= /*error:INVALID_ASSIGNMENT*/b; |
| 306 a <<= b; | 306 a <<= b; |
| 307 a >>= b; | 307 a >>= b; |
| 308 a &= b; | 308 a &= b; |
| 309 a ^= b; | 309 a ^= b; |
| 310 a |= b; | 310 a |= b; |
| 311 /*info:DYNAMIC_INVOKE*/c += b; | 311 /*info:DYNAMIC_INVOKE*/c += b; |
| 312 | 312 |
| 313 var d = new D(); | 313 var d = new D(); |
| 314 a[b] += d; | 314 a[b] += d; |
| 315 a[/*info:DYNAMIC_CAST*/c] += d; | 315 a[/*info:DYNAMIC_CAST*/c] += d; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 final List<Q> list = /*info:INFERRED_TYPE_LITERAL*/const []; | 366 final List<Q> list = /*info:INFERRED_TYPE_LITERAL*/const []; |
| 367 final Map<Q, Iterable<Q>> m = /*info:INFERRED_TYPE_LITERAL*/const {}; | 367 final Map<Q, Iterable<Q>> m = /*info:INFERRED_TYPE_LITERAL*/const {}; |
| 368 const C(); | 368 const C(); |
| 369 } | 369 } |
| 370 main() { | 370 main() { |
| 371 const SetEquality<String>(); | 371 const SetEquality<String>(); |
| 372 } | 372 } |
| 373 '''); | 373 '''); |
| 374 } | 374 } |
| 375 | 375 |
| 376 void test_compoundAssignment_returnsDynamic() { | |
| 377 checkFile(r''' | |
| 378 class Foo { | |
| 379 operator +(other) => null; | |
| 380 } | |
| 381 | |
| 382 main() { | |
| 383 var foo = new Foo(); | |
| 384 foo = /*info:DYNAMIC_CAST*/foo + 1; | |
| 385 /*info:DYNAMIC_CAST*/foo += 1; | |
| 386 } | |
| 387 '''); | |
| 388 } | |
| 389 | |
| 376 void test_constructorInvalid() { | 390 void test_constructorInvalid() { |
| 377 // Regression test for https://github.com/dart-lang/sdk/issues/26695 | 391 // Regression test for https://github.com/dart-lang/sdk/issues/26695 |
| 378 checkFile(''' | 392 checkFile(''' |
| 379 class A { | 393 class A { |
| 380 B({ /*error:FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR*/this.test: 1.0 }) {} | 394 B({ /*error:FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR*/this.test: 1.0 }) {} |
| 381 final double test = 0.0; | 395 final double test = 0.0; |
| 382 } | 396 } |
| 383 '''); | 397 '''); |
| 384 } | 398 } |
| 385 | 399 |
| (...skipping 3452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3838 } | 3852 } |
| 3839 | 3853 |
| 3840 void test_unaryOperators() { | 3854 void test_unaryOperators() { |
| 3841 checkFile(''' | 3855 checkFile(''' |
| 3842 class A { | 3856 class A { |
| 3843 A operator ~() => null; | 3857 A operator ~() => null; |
| 3844 A operator +(int x) => null; | 3858 A operator +(int x) => null; |
| 3845 A operator -(int x) => null; | 3859 A operator -(int x) => null; |
| 3846 A operator -() => null; | 3860 A operator -() => null; |
| 3847 } | 3861 } |
| 3862 class B extends A {} | |
| 3848 | 3863 |
| 3849 foo() => new A(); | 3864 foo() => new A(); |
| 3850 | 3865 |
| 3851 test() { | 3866 test() { |
| 3852 A a = new A(); | 3867 A a = new A(); |
| 3868 B b = new B(); | |
| 3853 var c = foo(); | 3869 var c = foo(); |
| 3854 dynamic d; | 3870 dynamic d; |
| 3855 | 3871 |
| 3856 ~a; | 3872 ~a; |
| 3857 (/*info:DYNAMIC_INVOKE*/~d); | 3873 (/*info:DYNAMIC_INVOKE*/~d); |
| 3858 | 3874 |
| 3859 !/*error:NON_BOOL_NEGATION_EXPRESSION*/a; | 3875 !/*error:NON_BOOL_NEGATION_EXPRESSION*/a; |
| 3860 !/*info:DYNAMIC_CAST*/d; | 3876 !/*info:DYNAMIC_CAST*/d; |
| 3861 | 3877 |
| 3862 -a; | 3878 -a; |
| 3863 (/*info:DYNAMIC_INVOKE*/-d); | 3879 (/*info:DYNAMIC_INVOKE*/-d); |
| 3864 | 3880 |
| 3865 ++a; | 3881 ++a; |
| 3866 --a; | 3882 --a; |
| 3867 (/*info:DYNAMIC_INVOKE*/++d); | 3883 (/*info:DYNAMIC_INVOKE*/++d); |
| 3868 (/*info:DYNAMIC_INVOKE*/--d); | 3884 (/*info:DYNAMIC_INVOKE*/--d); |
| 3869 | 3885 |
| 3870 a++; | 3886 a++; |
| 3871 a--; | 3887 a--; |
| 3872 (/*info:DYNAMIC_INVOKE*/d++); | 3888 (/*info:DYNAMIC_INVOKE*/d++); |
| 3873 (/*info:DYNAMIC_INVOKE*/d--); | 3889 (/*info:DYNAMIC_INVOKE*/d--); |
| 3890 | |
| 3891 ++/*info:DOWN_CAST_IMPLICIT_ASSIGN*/b; | |
| 3892 --/*info:DOWN_CAST_IMPLICIT_ASSIGN*/b; | |
| 3893 /*info:DOWN_CAST_IMPLICIT_ASSIGN*/b++; | |
| 3894 /*info:DOWN_CAST_IMPLICIT_ASSIGN*/b--; | |
|
Leaf
2016/09/22 22:30:17
Maybe test the case where we are assigning the res
Jennifer Messerly
2016/09/22 22:32:19
great idea! Adding.
| |
| 3874 }'''); | 3895 }'''); |
| 3875 } | 3896 } |
| 3876 | 3897 |
| 3877 void test_unboundRedirectingConstructor() { | 3898 void test_unboundRedirectingConstructor() { |
| 3878 // This is a regression test for https://github.com/dart-lang/sdk/issues/250 71 | 3899 // This is a regression test for https://github.com/dart-lang/sdk/issues/250 71 |
| 3879 checkFile(''' | 3900 checkFile(''' |
| 3880 class Foo { | 3901 class Foo { |
| 3881 Foo() : /*error:REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR*/this.init(); | 3902 Foo() : /*error:REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR*/this.init(); |
| 3882 } | 3903 } |
| 3883 '''); | 3904 '''); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 3914 void _addMetaLibrary() { | 3935 void _addMetaLibrary() { |
| 3915 addFile(r''' | 3936 addFile(r''' |
| 3916 library meta; | 3937 library meta; |
| 3917 class _Checked { const _Checked(); } | 3938 class _Checked { const _Checked(); } |
| 3918 const Object checked = const _Checked(); | 3939 const Object checked = const _Checked(); |
| 3919 | 3940 |
| 3920 class _Virtual { const _Virtual(); } | 3941 class _Virtual { const _Virtual(); } |
| 3921 const Object virtual = const _Virtual(); | 3942 const Object virtual = const _Virtual(); |
| 3922 ''', name: '/meta.dart'); | 3943 ''', name: '/meta.dart'); |
| 3923 } | 3944 } |
| OLD | NEW |