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

Unified Diff: tests/language/type_annotation_test.dart

Issue 11412245: MalformedType used for all invalid type annotations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Bug fixes Created 8 years, 1 month 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/type_annotation_test.dart
diff --git a/tests/language/type_annotation_test.dart b/tests/language/type_annotation_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..6ea2ca7fd987c1a12402f2fa31b3f41cc94ec0b0
--- /dev/null
+++ b/tests/language/type_annotation_test.dart
@@ -0,0 +1,53 @@
+// Copyright (c) 2012, 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 for type arguments and prefixes on special types.
+
+class C<T> {
+ C.named();
+
+ // This is a syntax error.
+ void<T> voidWithTypeArguments() {} /// 01: compile-time error
ahe 2012/11/30 15:44:07 void <T> /// 01: compile-time error voidWithTypeAr
Johnni Winther 2012/12/04 10:07:17 Done.
+
+ // This is a malformed type since 'dynamic' is not a generic type.
+ dynamic<T> dynamicWithTypeArguments() => new Object(); /// 02: static type warning, dynamic type error
+
+ // This is a syntax error.
+ void.suffix voidAsPrefix() {} /// 03: compile-time error
+
+ // This is a malformed type since since 'dynamic' is not a prefix and 'suffix'
+ // therefore cannot be resolved.
+ dynamic.suffix dynamicAsPrefix() => new Object(); /// 04: static type warning, dynamic type error
+
+ // This is a syntax error.
+ prefix.void voidWithPrefix() {} /// 05: compile-time error
+
+ // This is a malformed type since 'prefix' cannot be resolved.
+ prefix.dynamic dynamicWithPrefix() => new Object(); /// 06: static type warning, dynamic type error
+
+ // This is a malformed type since 'T' is not a generic type.
+ T<int> typeVariableWithTypeArguments() => new Object(); /// 07: static type warning, dynamic type error
+
+ // This is a malformed type since 'T' is in a static member and is not a
+ // generic type.
+ static T<int> staticTypeVariableWithTypeArguments() => new Object(); /// 08: static type warning, dynamic type error
+
+ // This is a malformed type since 'C' is not a prefix.
+ C.named constructorName() => new C.named(); /// 09: static type warning, dynamic type error
+}
+
+main() {
+ var c = new C<int>.named();
+
+ c.voidWithTypeArguments(); /// 01: continued
ahe 2012/11/30 15:44:07 May be able to remove "continued" tag if you follo
Johnni Winther 2012/12/04 10:07:17 Done.
+ c.dynamicWithTypeArguments(); /// 02: continued
+ c.voidAsPrefix(); /// 03: continued
+ c.dynamicAsPrefix(); /// 04: continued
+ c.voidWithPrefix(); /// 05: continued
+ c.dynamicWithPrefix(); /// 06: continued
+ c.typeVariableWithTypeArguments(); /// 07: continued
+ C.staticTypeVariableWithTypeArguments(); /// 08: continued
+ c.constructorName(); /// 09: continued
+}
+

Powered by Google App Engine
This is Rietveld 408576698