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

Unified Diff: pkg/kernel/testcases/reify/generic_methods_generic_class_tearoff_test.dart

Issue 2756693002: Add generic-methods 'golden' tests for 'reify' transformation (Closed)
Patch Set: Mark tests with Crash/Fail in reify.status instead of excluding 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: pkg/kernel/testcases/reify/generic_methods_generic_class_tearoff_test.dart
diff --git a/pkg/kernel/testcases/reify/generic_methods_generic_class_tearoff_test.dart b/pkg/kernel/testcases/reify/generic_methods_generic_class_tearoff_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..377af7b8a500f816a76739ec3912ed7985b482c4
--- /dev/null
+++ b/pkg/kernel/testcases/reify/generic_methods_generic_class_tearoff_test.dart
@@ -0,0 +1,43 @@
+// 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.
+
+// Test that a torn off method of a generic class is not a generic method,
+// and that it is correctly specialized.
+
+library generic_methods_generic_class_tearoff_test;
+
+import "test_base.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; // The type of f should be 'int Function(Object)'.
+ A<String> y = new A<String>();
+ var g = y.fun; // The type of g should be 'String Function(Object)'.
+ A z = new A();
+ var h = z.fun; // The type of h should be 'dynamic Function(Object)'.
+
+ expectTrue(f is Int2Int);
+ expectTrue(f is! String2String);
+ expectTrue(f is Object2Object);
+ expectTrue(f is! GenericMethod);
+
+ expectTrue(g is! Int2Int);
+ expectTrue(g is String2String);
+ expectTrue(g is Object2Object);
+ expectTrue(g is! GenericMethod);
+
+ expectTrue(h is! Int2Int);
+ expectTrue(h is! String2String);
+ expectTrue(h is Object2Object);
+ expectTrue(h is! GenericMethod);
+}

Powered by Google App Engine
This is Rietveld 408576698