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

Unified Diff: tests/language/const_types_test.dart

Issue 34993002: Check const expressions for malformed types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Status updated Created 7 years, 2 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/co19/co19-dart2js.status ('k') | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/const_types_test.dart
diff --git a/tests/language/const_types_test.dart b/tests/language/const_types_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..9a4a46a43f4279897339c5955e113a253e1b9794
--- /dev/null
+++ b/tests/language/const_types_test.dart
@@ -0,0 +1,84 @@
+// 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.
+
+// Test handling of malformed types in constant expressions.
+
+use(x) {}
+
+class Class<T> implements Superclass {
+ const Class();
+ const Class.named();
+
+ void test() {
+ use(const []);
+ use(const <Class>[]);
+ use(const <Class<int>>[]);
+ use(const <Class<Unresolved>>[]); /// 01: static type warning
+ use(const <Unresolved>[]); /// 02: static type warning
+
+ use(const {});
+ use(const <Class>{}); /// 03: static type warning
+ use(const <String, Class>{});
+ use(const <String, Class<int>>{});
+ use(const <String, Class<Unresolved>>{}); /// 04: static type warning
+ use(const <String, Unresolved>{}); /// 05: static type warning
+
+ use(const Class());
+ use(const Class<int>());
+ use(const Class<Unresolved>()); /// 06: static type warning
+ use(const Class<T>()); /// 07: compile-time error
+ use(const Class<Class<T>>()); /// 08: compile-time error
+
+ use(const Unresolved()); /// 09: compile-time error
+ use(const Unresolved<int>()); /// 10: compile-time error
+ use(const prefix.Unresolved()); /// 11: compile-time error
+ use(const prefix.Unresolved<int>()); /// 12: compile-time error
+
+ use(const Class.named());
+ use(const Class<int>.named());
+ use(const Class<Unresolved>.named()); /// 13: static type warning
+ use(const Class<T>.named()); /// 14: compile-time error
+ use(const Class<Class<T>>.named()); /// 15: compile-time error
+
+ use(const Class.nonamed()); /// 16: compile-time error
+ use(const Class<int>.nonamed()); /// 17: compile-time error
+ use(const Class<Unresolved>.nonamed()); /// 18: compile-time error
+ use(const Class<T>.nonamed()); /// 19: compile-time error
+ use(const Class<Class<T>>.nonamed()); /// 20: compile-time error
+
+ use(const Unresolved.named()); /// 21: compile-time error
+ use(const Unresolved<int>.named()); /// 22: compile-time error
+ }
+}
+
+class Superclass<T> {
+ const factory Superclass() = Unresolved; /// 23: compile-time error
+ const factory Superclass() = Unresolved<int>; /// 24: compile-time error
+ const factory Superclass() = Unresolved.named; /// 25: compile-time error
+ const factory Superclass() = Unresolved<int>.named; /// 26: compile-time error
+
+ const factory Superclass() = prefix.Unresolved; /// 27: compile-time error
+ const factory Superclass() = prefix.Unresolved<int>; /// 28: compile-time error
+ const factory Superclass() = prefix.Unresolved.named; /// 29: compile-time error
+ const factory Superclass() = prefix.Unresolved<int>.named; /// 30: compile-time error
+
+ const factory Superclass() = Class; /// 31: ok
+ const factory Superclass() = Class<int>; /// 32: ok
+ const factory Superclass() = Class<T>; /// 33: ok
+ const factory Superclass() = Class<Class<T>>; /// 34: ok
+ const factory Superclass() = Class<Unresolved>; /// 35: static type warning
+
+ const factory Superclass() = Class.named; /// 36: ok
+ const factory Superclass() = Class<int>.named; /// 37: ok
+ const factory Superclass() = Class<T>.named; /// 38: ok
+ const factory Superclass() = Class<Class<T>>.named; /// 39: ok
+ const factory Superclass() = Class<Unresolved>.named; /// 40: static type warning
+
+ const factory Superclass() = T; /// 41: compile-time error
+}
+
+void main() {
+ new Class().test();
+ new Superclass();
+}
« no previous file with comments | « tests/co19/co19-dart2js.status ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698