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

Unified Diff: pkg/dev_compiler/test/codegen/language/checked_covariant_overrides_test.dart

Issue 2340463009: fix #27353, support `@checked` covariant parameters in DDC (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « pkg/dev_compiler/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/test/codegen/language/checked_covariant_overrides_test.dart
diff --git a/pkg/dev_compiler/test/codegen/language/checked_covariant_overrides_test.dart b/pkg/dev_compiler/test/codegen/language/checked_covariant_overrides_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..6f538dcae3d064bc114b2f293d2d545ab903007e
--- /dev/null
+++ b/pkg/dev_compiler/test/codegen/language/checked_covariant_overrides_test.dart
@@ -0,0 +1,36 @@
+// Copyright (c) 2016, 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.
+
+import "package:expect/expect.dart";
+import 'package:meta/meta.dart' show checked;
+
+// Test runtime behavior of @checked
+
+class View {
+ addChild(View v) {}
+ transform(View fn(View v)) {}
+}
+class MyView extends View {
+ addChild(@checked MyView v) {}
+ transform(@checked MyView fn(Object v)) {}
+}
+
+main() {
+ dynamic mv = new MyView();
+ dynamic v = new View();
+
+ mv.addChild(mv);
+ Expect.throws(() => mv.addChild(v));
+
+ mv.transform((_) => new MyView());
+
+ // TODO(jmesserly): these *should* be a cast failures, but DDC is currently
+ // ignoring function type failures w/ a warning at the console...
+
+ // * -> * not a subtype of Object -> MyView
+ // Expect.throws(() => mv.transform((_) => mv));
+
+ // View -> View not a subtype of Object -> MyView
+ // Expect.throws(() => mv.transform((View x) => x));
+}
« no previous file with comments | « pkg/dev_compiler/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698