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 3681 matching lines...) Loading... | |
3692 Object x; | 3692 Object x; |
3693 if (x is int) { | 3693 if (x is int) { |
3694 int y = x; | 3694 int y = x; |
3695 String z = /*error:INVALID_ASSIGNMENT*/x; | 3695 String z = /*error:INVALID_ASSIGNMENT*/x; |
3696 } | 3696 } |
3697 } | 3697 } |
3698 '''); | 3698 '''); |
3699 } | 3699 } |
3700 | 3700 |
3701 void test_typePromotionFromTypeParameter() { | 3701 void test_typePromotionFromTypeParameter() { |
3702 // Regression test for https://github.com/dart-lang/sdk/issues/26965 | 3702 // Regression test for: |
3703 // https://github.com/dart-lang/sdk/issues/26965 | |
3704 // https://github.com/dart-lang/sdk/issues/27040 | |
3703 checkFile(r''' | 3705 checkFile(r''' |
3704 void f/*<T>*/(/*=T*/ object) { | 3706 void f/*<T>*/(/*=T*/ object) { |
3705 if (object is String) print(object.substring(1)); | 3707 if (object is String) print(object.substring(1)); |
3706 } | 3708 } |
3707 void g/*<T extends num>*/(/*=T*/ object) { | 3709 void g/*<T extends num>*/(/*=T*/ object) { |
3708 if (object is int) print(object.isEven); | 3710 if (object is int) print(object.isEven); |
3709 if (object is String) print(/*info:DYNAMIC_INVOKE*/object.substring(1)); | 3711 if (object is String) print(/*info:DYNAMIC_INVOKE*/object.substring(1)); |
3710 } | 3712 } |
3711 class Clonable<T> {} | 3713 class Clonable<T> {} |
3712 class SubClonable<T> extends Clonable<T> { | 3714 class SubClonable<T> extends Clonable<T> { |
3713 T m(T t) => t; | 3715 T m(T t) => t; |
3714 } | 3716 } |
3715 void h/*<T extends Clonable<T>>*/(/*=T*/ object) { | 3717 void h/*<T extends Clonable<T>>*/(/*=T*/ object) { |
Leaf
2016/09/30 05:00:04
Test that object is usable as a SubClonable<T> as
Jennifer Messerly
2016/09/30 16:58:03
I think `object.m` is supposed to illustrate that.
Leaf
2016/09/30 17:00:30
Sort of. object.m tests that SubClonable methods
| |
3716 if (/*info:NON_GROUND_TYPE_CHECK_INFO*/object is SubClonable/*<T>*/) { | 3718 if (/*info:NON_GROUND_TYPE_CHECK_INFO*/object is SubClonable/*<T>*/) { |
3717 // Note we need to cast back to T, because promotion lost that type info. | 3719 print(object.m(object)); |
3718 print(object.m(object as dynamic/*=T*/)); | |
3719 } | 3720 } |
3720 } | 3721 } |
3721 '''); | 3722 '''); |
3722 } | 3723 } |
3723 | 3724 |
3724 void test_typeSubtyping_assigningClass() { | 3725 void test_typeSubtyping_assigningClass() { |
3725 checkFile(''' | 3726 checkFile(''' |
3726 class A {} | 3727 class A {} |
3727 class B extends A {} | 3728 class B extends A {} |
3728 | 3729 |
(...skipping 220 matching lines...) Loading... | |
3949 void _addMetaLibrary() { | 3950 void _addMetaLibrary() { |
3950 addFile(r''' | 3951 addFile(r''' |
3951 library meta; | 3952 library meta; |
3952 class _Checked { const _Checked(); } | 3953 class _Checked { const _Checked(); } |
3953 const Object checked = const _Checked(); | 3954 const Object checked = const _Checked(); |
3954 | 3955 |
3955 class _Virtual { const _Virtual(); } | 3956 class _Virtual { const _Virtual(); } |
3956 const Object virtual = const _Virtual(); | 3957 const Object virtual = const _Virtual(); |
3957 ''', name: '/meta.dart'); | 3958 ''', name: '/meta.dart'); |
3958 } | 3959 } |
OLD | NEW |