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

Unified Diff: pkg/kernel/testcases/closures/closure_types.dart

Issue 3007623002: Fix many bugs with closure conversion in checked mode. (Closed)
Patch Set: Review comments Created 3 years, 4 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/closures/closure_types.dart
diff --git a/pkg/kernel/testcases/closures/closure_types.dart b/pkg/kernel/testcases/closures/closure_types.dart
new file mode 100644
index 0000000000000000000000000000000000000000..86fc3e08e20f3b8ec1d2c883cdce060501ce35ab
--- /dev/null
+++ b/pkg/kernel/testcases/closures/closure_types.dart
@@ -0,0 +1,55 @@
+// 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.md file.
+//
+// This tests checks that the runtime types of converted closures are asessed
+// correctly in is-tests.
+
+class C<T> {
+ void getf() {
+ T fn(T x) {
+ return x;
+ }
+
+ ;
+ return fn;
+ }
+}
+
+typedef void ct(int x);
+
+void test_c() {
+ var x = new C<int>().getf();
+ assert(x is ct);
+
+ var y = new C<String>().getf();
+ assert(y is! ct);
+}
+
+class D<T> {
+ void getf<S>() {
+ T fn(S y) {
+ return null;
+ }
+
+ return fn;
+ }
+}
+
+typedef String dt(int x);
+
+void test_d() {
+ var x = new D<String>().getf<int>();
+ assert(x is dt);
+
+ var y = new D<int>().getf<int>();
+ assert(y is! dt);
+
+ var z = new D<int>().getf<String>();
+ assert(z is! dt);
+}
+
+main() {
+ test_c();
+ test_d();
+}

Powered by Google App Engine
This is Rietveld 408576698