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

Unified Diff: tests/language/closure_in_field_test.dart

Issue 2994383003: Avoid crash for type variables in mixed in fields. (Closed)
Patch Set: 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: tests/language/closure_in_field_test.dart
diff --git a/tests/language/closure_in_field_test.dart b/tests/language/closure_in_field_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..95a7bd5a68d30c04c5170fa98d00d59ce342194a
--- /dev/null
+++ b/tests/language/closure_in_field_test.dart
@@ -0,0 +1,22 @@
+// 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 handling of type variable in field initializers.
+
+import 'package:expect/expect.dart';
+
+class Mixin<S> {
+ var field = (S s) => null;
+}
+
+class Class<T> extends Object with Mixin<T> {}
+
+void main() {
+ Expect.isTrue(test(new Mixin<int>()));
+ Expect.isFalse(test(new Mixin<String>())); //# 01: ok
+ Expect.isTrue(test(new Class<int>()));
+ Expect.isFalse(test(new Class<String>())); //# 02: ok
+}
+
+test(o) => o.field is dynamic Function(int);

Powered by Google App Engine
This is Rietveld 408576698