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

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

Issue 2540903003: restrict generic function type subtyping (Closed)
Patch Set: fix 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..c4c894a698219b09c6839992783621b5cd8c6f08 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'''
+T foo<T>(T x) => x;
+
+void takesDtoD(dynamic f(dynamic x)) {}
+
+void test() {
+ // here we currently infer an instantiation.
+ takesDtoD(/*pass should be error:INVALID_ASSIGNMENT*/foo);
Leaf 2016/12/02 01:59:10 I think if you make it dynamic foo<T>(dynamic x)
Jennifer Messerly 2016/12/02 03:24:00 hmmm, tried it and it's still too smart to infer.
+}
+
+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('''

Powered by Google App Engine
This is Rietveld 408576698