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

Unified Diff: tests/language/deferred_constraints_test.dart

Issue 177543002: Constrain type annotations with deferred types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
Index: tests/language/deferred_constraints_test.dart
diff --git a/tests/language/deferred_constraints_test.dart b/tests/language/deferred_constraints_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..9ac8d4de029f8fd11903de19cb24750f76609c09
--- /dev/null
+++ b/tests/language/deferred_constraints_test.dart
@@ -0,0 +1,50 @@
+// 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.
+
+import "dart:async";
+import 'package:expect/expect.dart';
+
+@lazy import "deferred_constraints_lib.dart" as lib;
+import "deferred_constraints_lib.dart" as lib2; /// type_annotation_non_deferred: ok
+
+const lazy = const DeferredLibrary('lib');
+
+class F {}
+class G2<T> {}
+
+void main() {
+ Expect.throws(() { /// type_annotation1: static type warning
+ lib.C a = new lib.C(); /// type_annotation1: continued
+ }, (e) => e is NoSuchMethodError); /// type_annotation1: continued
+ lib.C a = null; /// type_annotation_null: static type warning
+
+ // In this case we do not defer C.
+ lib2.C a1 = new lib2.C(); /// type_annotation_non_deferred: continued
+ lazy.load().then((_) {
+ lib.C a2 = new lib.C(); /// type_annotation2: dynamic type error, static type warning
+ lib.G<F> a3 = new lib.G<F>(); /// type_annotation_generic1: dynamic type error, static type warning
+ G2<lib.C> a4 = new G2(); /// type_annotation_generic2: static type warning
+ G2<lib.C> a5 = new G2<lib.C>(); /// type_annotation_generic3: static type warning
+ lib.G<lib.C> a = new lib.G<lib.C>(); /// type_annotation_generic4: dynamic type error, static type warning
+ var a6 = new lib.C(); /// new: ok
+ var g1 = new lib.G<F>(); /// new_generic1: ok
+ // new G2<lib.C>() does not give a dynamic type error because a malformed
+ // type used as type-parameter is treated as dynamic.
+ var g2 = new G2<lib.C>(); /// new_generic2: static type warning
+ var g3 = new lib.G<lib.C>(); /// new_generic3: static type warning
floitsch 2014/03/06 15:25:02 Not for this CL, but I think this is going to bite
+ var instance = lib.constantInstance;
+ Expect.throws(() { /// is_check: static type warning
+ bool a7 = instance is lib.Const; /// is_check: continued
+ }, (e) => e is TypeError); /// is_check: continued
+ Expect.throws(() { /// as_operation: static type warning
+ instance as lib.Const; /// as_operation: continued
+ }, (e) => e is TypeError); /// as_operation: continued
+ Expect.throws(() { /// catch_check: static type warning
+ try { throw instance; } on lib.Const {} /// catch_check: continued
+ }, (e) => e is TypeError); /// catch_check: continued
+ int i = lib.C.staticMethod(); /// static_method: ok
+ });
+}
+
+lib.C a9 = null; /// type_annotation_top_level: static type warning

Powered by Google App Engine
This is Rietveld 408576698