Chromium Code Reviews| Index: pkg/analyzer/test/src/task/strong/checker_test.dart |
| diff --git a/pkg/analyzer/test/src/task/strong/checker_test.dart b/pkg/analyzer/test/src/task/strong/checker_test.dart |
| index 8bdd4ce38ac9f40e19f724610d096de008f93c69..860c15e780294df7abc778b4f178d644d025084e 100644 |
| --- a/pkg/analyzer/test/src/task/strong/checker_test.dart |
| +++ b/pkg/analyzer/test/src/task/strong/checker_test.dart |
| @@ -3406,6 +3406,29 @@ g() { |
| '''); |
| } |
| + void test_typePromotionFromTypeParameter() { |
| + // Regression test for https://github.com/dart-lang/sdk/issues/26965 |
| + checkFile(r''' |
| +void f/*<T>*/(/*=T*/ object) { |
| + if (object is String) print(object.substring(1)); |
| +} |
| +void g/*<T extends num>*/(/*=T*/ object) { |
| + if (object is int) print(object.isEven); |
| + if (object is String) print(/*info:DYNAMIC_INVOKE*/object.substring(1)); |
|
Leaf
2016/08/04 16:49:06
There should be a type error here, shouldn't there
Jennifer Messerly
2016/08/04 18:26:16
yeah, it is, but we suppress the UNDEFINED_METHOD
|
| +} |
| +class Clonable<T> {} |
| +class SubClonable<T> extends Clonable<T> { |
| + T m(T t) => t; |
| +} |
| +void h/*<T extends Clonable<T>>*/(/*=T*/ object) { |
| + if (/*info:NON_GROUND_TYPE_CHECK_INFO*/object is SubClonable/*<T>*/) { |
| + // Note we need to cast back to T, because promotion lost that type info. |
| + print(object.m(object as dynamic/*=T*/)); |
| + } |
| +} |
| +'''); |
| + } |
| + |
| void test_typeSubtyping_assigningClass() { |
| checkFile(''' |
| class A {} |