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

Unified Diff: pkg/analyzer/test/src/task/strong/checker_test.dart

Issue 2214833002: fix #26965, allow promotion from type param upper bound in strong mode (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/type_system.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0025383253f9b2f3e9af3aca78194f89111c3948..f7ce4b20f518dcefde77a55728b50f58ddc6dfe7 100644
--- a/pkg/analyzer/test/src/task/strong/checker_test.dart
+++ b/pkg/analyzer/test/src/task/strong/checker_test.dart
@@ -3422,6 +3422,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));
+}
+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 {}
« no previous file with comments | « pkg/analyzer/lib/src/generated/type_system.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698