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

Unified Diff: pkg/analyzer/test/src/task/strong/checker_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
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 6c22865f6308266d456bfa7690ae1df59a61ae91..6ad54c7183b5b905683111a305c2bc14f3896f7f 100644
--- a/pkg/analyzer/test/src/task/strong/checker_test.dart
+++ b/pkg/analyzer/test/src/task/strong/checker_test.dart
@@ -3991,6 +3991,27 @@ void main() {
''');
}
+ void test_universalFunctionSubtyping() {
+ checkFile(r'''
+dynamic foo<T>(dynamic x) => x;
+
+void takesDtoD(dynamic f(dynamic x)) {}
+
+void test() {
+ // here we currently infer an instantiation.
+ takesDtoD(/*pass should be error:INVALID_ASSIGNMENT*/foo);
+}
+
+class A {
+ dynamic method(dynamic x) => x;
+}
+
+class B extends A {
+ /*error:INVALID_METHOD_OVERRIDE*/T method<T>(T x) => x;
+}
+ ''');
+ }
+
void test_voidSubtyping() {
// Regression test for https://github.com/dart-lang/sdk/issues/25069
checkFile('''
« no previous file with comments | « pkg/analyzer/test/generated/type_system_test.dart ('k') | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698