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

Unified Diff: test/codegen/covariance.dart

Issue 1117793002: add checks needed for covariant generics, and List<E> (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 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 | « test/browser/runtime_tests.js ('k') | test/codegen/expect/covariance.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/covariance.dart
diff --git a/test/codegen/covariance.dart b/test/codegen/covariance.dart
new file mode 100644
index 0000000000000000000000000000000000000000..89c27615a523fedc6f4e536c89e221892b84b070
--- /dev/null
+++ b/test/codegen/covariance.dart
@@ -0,0 +1,27 @@
+// Copyright (c) 2015, 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.
+
+class Foo<T> {
+ T _t;
+ add(T t) {
+ _t = t;
+ }
+
+ forEach(void fn(T t)) {
+ // No check needed for `fn`
+ fn(_t);
+ }
+}
+
+class Bar extends Foo<int> {
+ add(int x) {
+ print('Bar.add got $x');
+ super.add(x);
+ }
+}
+
+main() {
+ Foo<Object> foo = new Bar();
+ foo.add('hi'); // should throw
+}
« no previous file with comments | « test/browser/runtime_tests.js ('k') | test/codegen/expect/covariance.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698