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

Unified Diff: pkg/analyzer/test/generated/type_system_test.dart

Issue 2540903003: restrict generic function type subtyping (Closed)
Patch Set: patch Created 4 years 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/task/strong/checker.dart ('k') | pkg/analyzer/test/src/task/strong/checker_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/type_system_test.dart
diff --git a/pkg/analyzer/test/generated/type_system_test.dart b/pkg/analyzer/test/generated/type_system_test.dart
index 6aa2ad152ee9a8bd88438adcae751e4ab20ea842..c555954667b3ec7ee3b9b923ca644a86d0fba10e 100644
--- a/pkg/analyzer/test/generated/type_system_test.dart
+++ b/pkg/analyzer/test/generated/type_system_test.dart
@@ -1608,15 +1608,42 @@ class StrongSubtypingTest {
DartType u = TypeBuilder.variable("U", bound: intType);
DartType v = TypeBuilder.variable("V", bound: u);
+ DartType a = TypeBuilder.variable("A");
+ DartType b = TypeBuilder.variable("B", bound: a);
+ DartType c = TypeBuilder.variable("C", bound: intType);
+ DartType d = TypeBuilder.variable("D", bound: c);
+
_checkIsStrictSubtypeOf(
TypeBuilder.function(types: [s, t], required: [s], result: t),
+ TypeBuilder.function(
+ types: [a, b], required: [dynamicType], result: dynamicType));
+
+ _checkIsNotSubtypeOf(
+ TypeBuilder.function(types: [u, v], required: [u], result: v),
+ TypeBuilder.function(
+ types: [c, d], required: [objectType], result: objectType));
+
+ _checkIsNotSubtypeOf(
+ TypeBuilder.function(types: [u, v], required: [u], result: v),
+ TypeBuilder
+ .function(types: [c, d], required: [intType], result: intType));
+ }
+
+ void test_genericFunction_genericDoesNotSubtypeNonGeneric() {
+ DartType s = TypeBuilder.variable("S");
+ DartType t = TypeBuilder.variable("T", bound: s);
+ DartType u = TypeBuilder.variable("U", bound: intType);
+ DartType v = TypeBuilder.variable("V", bound: u);
+
+ _checkIsNotSubtypeOf(
+ TypeBuilder.function(types: [s, t], required: [s], result: t),
TypeBuilder.function(required: [dynamicType], result: dynamicType));
_checkIsNotSubtypeOf(
TypeBuilder.function(types: [u, v], required: [u], result: v),
TypeBuilder.function(required: [objectType], result: objectType));
- _checkIsStrictSubtypeOf(
+ _checkIsNotSubtypeOf(
TypeBuilder.function(types: [u, v], required: [u], result: v),
TypeBuilder.function(required: [intType], result: intType));
}
« no previous file with comments | « pkg/analyzer/lib/src/task/strong/checker.dart ('k') | pkg/analyzer/test/src/task/strong/checker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698