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

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

Issue 1678313002: fix part of #25200, reject non-generic function subtype of generic function (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix synthetic ctor Created 4 years, 10 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
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 0a009618a1ceba41a2d885edf0b92cfa30f8c8a4..cc7047e425acd22909232c83024986f4099dbd7c 100644
--- a/pkg/analyzer/test/src/task/strong/checker_test.dart
+++ b/pkg/analyzer/test/src/task/strong/checker_test.dart
@@ -1161,12 +1161,47 @@ void main() {
test('uninferred closure', () {
checkFile('''
- typedef num Num2Num(num x);
- void main() {
- Num2Num g = /*info:INFERRED_TYPE_CLOSURE,severe:STATIC_TYPE_ERROR*/(int x) { return x; };
- print(g(42));
- }
- ''');
+ typedef num Num2Num(num x);
+ void main() {
+ Num2Num g = /*info:INFERRED_TYPE_CLOSURE,severe:STATIC_TYPE_ERROR*/(int x) { return x; };
+ print(g(42));
+ }
+ ''');
+ });
+
+ test('subtype of universal type', () {
+ checkFile('''
+ void main() {
+ nonGenericFn(x) => null;
+ {
+ /*=R*/ f/*<P, R>*/(/*=P*/ p) => null;
+ /*=T*/ g/*<S, T>*/(/*=S*/ s) => null;
+
+ var local = f;
+ local = g; // valid
+
+ // Non-generic function cannot subtype a generic one.
+ local = /*severe:STATIC_TYPE_ERROR*/(x) => null;
+ local = /*severe:STATIC_TYPE_ERROR*/nonGenericFn;
+ }
+ {
+ Iterable/*<R>*/ f/*<P, R>*/(List/*<P>*/ p) => null;
+ List/*<T>*/ g/*<S, T>*/(Iterable/*<S>*/ s) => null;
+
+ var local = f;
+ local = g; // valid
+
+ var local2 = g;
+ local = local2;
+ local2 = /*severe:STATIC_TYPE_ERROR*/f;
+ local2 = /*warning:DOWN_CAST_COMPOSITE*/local;
+
+ // Non-generic function cannot subtype a generic one.
+ local = /*severe:STATIC_TYPE_ERROR*/(x) => null;
+ local = /*severe:STATIC_TYPE_ERROR*/nonGenericFn;
+ }
+ }
+ ''');
});
});
@@ -2597,8 +2632,8 @@ void main() {
// different.
// TODO(sigmund): should we merge these as well?
class T1 extends Object
- with /*severe:INVALID_METHOD_OVERRIDE*/M1
- with /*severe:INVALID_METHOD_OVERRIDE*/M2
+ with /*severe:INVALID_METHOD_OVERRIDE*/M1,
+ /*severe:INVALID_METHOD_OVERRIDE*/M2
implements I1 {
}
''');
« no previous file with comments | « pkg/analyzer/lib/src/generated/type_system.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