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

Unified Diff: pkg/dev_compiler/test/codegen/lib/collection/list_test.dart

Issue 2544163002: Fix runtime strong mode error in ListMixin (Closed)
Patch Set: Created 4 years 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/test/browser/language_tests.js ('k') | pkg/dev_compiler/test/codegen_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/test/codegen/lib/collection/list_test.dart
diff --git a/pkg/dev_compiler/test/codegen/lib/collection/list_test.dart b/pkg/dev_compiler/test/codegen/lib/collection/list_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..76cd515a92deef17a0305a257a0b7e934d2ee856
--- /dev/null
+++ b/pkg/dev_compiler/test/codegen/lib/collection/list_test.dart
@@ -0,0 +1,40 @@
+// Copyright (c) 2013, 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 'dart:collection';
+import "package:expect/expect.dart";
+
+class MyList<E> extends Object with ListMixin<E> implements List<E> {
+ List<E> _list;
+
+ MyList(List<E> this._list);
+
+ int get length => _list.length;
+
+ void set length(int x) {
+ _list.length = x;
+ }
+
+ E operator[](int idx) => _list[idx];
+
+ void operator[]=(int idx, E value) {
+ _list[idx] = value;
+ }
+}
+
+void testRetainWhere() {
+ List<int> list = <int>[1, 2, 3];
+ list.retainWhere((x) => x % 2 == 0);
+ Expect.equals(1, list.length);
+ Expect.equals(2, list.first);
+
+ list = new MyList<int>([1, 2, 3]);
vsm 2016/12/01 23:33:54 FYI: The strong mode error only kicked in here pri
+ list.retainWhere((x) => x % 2 == 0);
+ Expect.equals(1, list.length);
+ Expect.equals(2, list.first);
+}
+
+void main() {
+ testRetainWhere();
+}
« no previous file with comments | « pkg/dev_compiler/test/browser/language_tests.js ('k') | pkg/dev_compiler/test/codegen_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698