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

Unified Diff: tests/lib/mirrors/metadata_nested_constructor_call_test.dart

Issue 180313003: Fix VM crash when parsing what looks like a closure call during metadata evaluation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: comment Created 6 years, 10 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 | « tests/lib/lib.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/metadata_nested_constructor_call_test.dart
diff --git a/tests/lib/mirrors/metadata_nested_constructor_call_test.dart b/tests/lib/mirrors/metadata_nested_constructor_call_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7b50b6796f60bbe2348b44c478e965f11b2cd10d
--- /dev/null
+++ b/tests/lib/mirrors/metadata_nested_constructor_call_test.dart
@@ -0,0 +1,83 @@
+// Copyright (c) 2014, 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.
+
+// Regression test for Issue 17141.
+
+library test.metadata_nested_constructor_call;
+
+import 'dart:mirrors';
+import 'package:expect/expect.dart';
+
+class Box {
+ final contents;
+ const Box([this.contents]);
+}
+
+class MutableBox {
+ var contents;
+ MutableBox([this.contents]); // Not const.
+}
+
+@Box()
+class A {}
+
+@Box(const Box())
+class B {}
+
+@Box(const Box(const Box()))
+class C {}
+
+@Box(const Box(const MutableBox())) /// 01: compile-time error
+class D {}
+
+@Box(const MutableBox(const Box())) /// 02: compile-time error
+class E {}
+
+@Box(Box()) /// 03: compile-time error
+class F {}
+
+@Box(Box(const Box())) /// 04: compile-time error
+class G {}
+
+@Box(Box(const MutableBox())) /// 05: compile-time error
+class H {}
+
+@Box(MutableBox(const Box())) /// 06: compile-time error
+class I {}
+
+final closure = () => 42;
+@Box(closure()) /// 07: compile-time error
+class J {}
+
+@Box(closure) /// 08: compile-time error
+class K {}
+
+function() => 42;
+@Box(function()) /// 09: compile-time error
+class L {}
+
+// N.B. This is legal, but @function is not (tested by metadata_allowed_values).
+@Box(function)
+class M {}
+
+checkMetadata(DeclarationMirror mirror, List expectedMetadata) {
+ Expect.listEquals(expectedMetadata.map(reflect).toList(), mirror.metadata);
+}
+
+main() {
+ closure();
+ checkMetadata(reflectClass(A), [const Box()]);
+ checkMetadata(reflectClass(B), [const Box(const Box())]);
+ checkMetadata(reflectClass(C), [const Box(const Box(const Box()))]);
+ reflectClass(D).metadata;
+ reflectClass(E).metadata;
+ reflectClass(F).metadata;
+ reflectClass(G).metadata;
+ reflectClass(H).metadata;
+ reflectClass(I).metadata;
+ reflectClass(J).metadata;
+ reflectClass(K).metadata;
+ reflectClass(L).metadata;
+ reflectClass(M).metadata;
+}
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698