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

Unified Diff: tests/language_strong/generic_methods_generic_class_tearoff_test.dart

Issue 2737933002: Add tests for generic methods in strong mode (Closed)
Patch Set: Created 3 years, 9 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: tests/language_strong/generic_methods_generic_class_tearoff_test.dart
diff --git a/tests/language_strong/generic_methods_generic_class_tearoff_test.dart b/tests/language_strong/generic_methods_generic_class_tearoff_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..69076cdaf0ee2278d8f8371df51dafeccffc6f70
--- /dev/null
+++ b/tests/language_strong/generic_methods_generic_class_tearoff_test.dart
@@ -0,0 +1,40 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library generic_methods_generic_class_tearoff_test;
+
+import "package:expect/expect.dart";
+
+class A<T> {
+ T fun(T t) => t;
+}
+
+typedef Int2Int = int Function(int);
+typedef String2String = String Function(String);
+typedef Object2Object = Object Function(Object);
+typedef GenericMethod = T Function<T>(T);
+
+main() {
+ A<int> x = new A<int>();
+ var f = x.fun;
+ A<String> y = new A<String>();
+ var g = y.fun;
+ A z = new A();
eernst 2017/03/09 14:55:02 This one depends on instantiate-to-bound for a raw
Dmitry Stefantsov 2017/03/10 13:21:53 Thank you! Done.
+ var h = z.fun;
+
+ Expect.isTrue(f is Int2Int);
+ Expect.isTrue(f is! String2String);
+ Expect.isTrue(f is! Object2Object);
Leaf 2017/03/09 05:51:19 I think this one should be true. The reified type
karlklose 2017/03/09 09:17:00 Why is it not `int -> int`?
karlklose 2017/03/09 09:18:53 Or do you mean that 'int -> int' is a subtype of '
floitsch 2017/03/09 11:27:17 Because of covariant generics. We have to support:
Leaf 2017/03/09 19:17:26 Is the writeup of that ready to share yet?
eernst 2017/03/10 13:13:51 We did that already: https://github.com/dart-lang/
Dmitry Stefantsov 2017/03/10 13:21:53 Thank you! That explains a lot.
+ Expect.isTrue(f is! GenericMethod);
+
+ Expect.isTrue(g is! Int2Int);
+ Expect.isTrue(g is String2String);
+ Expect.isTrue(g is! Object2Object);
Leaf 2017/03/09 05:51:18 As above.
Dmitry Stefantsov 2017/03/10 13:21:53 Done.
+ Expect.isTrue(g is! GenericMethod);
+
+ Expect.isTrue(h is! Int2Int);
+ Expect.isTrue(h is! String2String);
+ Expect.isTrue(h is Object2Object);
+ Expect.isTrue(h is! GenericMethod);
+}

Powered by Google App Engine
This is Rietveld 408576698