Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import "dart:async"; | |
| 6 import 'package:expect/expect.dart'; | |
| 7 | |
| 8 @lazy import "deferred_constraints_lib.dart" as lib; | |
| 9 import "deferred_constraints_lib.dart" as lib2; /// type_annotation_non_deferred : ok | |
| 10 | |
| 11 const lazy = const DeferredLibrary('lib'); | |
| 12 | |
| 13 class F {} | |
| 14 class G2<T> {} | |
| 15 | |
| 16 void main() { | |
| 17 Expect.throws(() { /// type_annotation1: static type warning | |
| 18 lib.C a = new lib.C(); /// type_annotation1: continued | |
| 19 }, (e) => e is NoSuchMethodError); /// type_annotation1: continued | |
| 20 lib.C a = null; /// type_annotation_null: static type warning | |
| 21 | |
| 22 // In this case we do not defer C. | |
| 23 lib2.C a1 = new lib2.C(); /// type_annotation_non_deferred: continued | |
| 24 lazy.load().then((_) { | |
| 25 lib.C a2 = new lib.C(); /// type_annotation2: dynamic type error, static typ e warning | |
| 26 lib.G<F> a3 = new lib.G<F>(); /// type_annotation_generic1: dynamic type err or, static type warning | |
| 27 G2<lib.C> a4 = new G2(); /// type_annotation_generic2: static type warning | |
| 28 G2<lib.C> a5 = new G2<lib.C>(); /// type_annotation_generic3: static type wa rning | |
| 29 lib.G<lib.C> a = new lib.G<lib.C>(); /// type_annotation_generic4: dynamic t ype error, static type warning | |
| 30 var a6 = new lib.C(); /// new: ok | |
| 31 var g1 = new lib.G<F>(); /// new_generic1: ok | |
| 32 // new G2<lib.C>() does not give a dynamic type error because a malformed | |
| 33 // type used as type-parameter is treated as dynamic. | |
| 34 var g2 = new G2<lib.C>(); /// new_generic2: static type warning | |
| 35 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
| |
| 36 var instance = lib.constantInstance; | |
| 37 Expect.throws(() { /// is_check: static type warning | |
| 38 bool a7 = instance is lib.Const; /// is_check: continued | |
| 39 }, (e) => e is TypeError); /// is_check: continued | |
| 40 Expect.throws(() { /// as_operation: static type warning | |
| 41 instance as lib.Const; /// as_operation: continued | |
| 42 }, (e) => e is TypeError); /// as_operation: continued | |
| 43 Expect.throws(() { /// catch_check: static type warning | |
| 44 try { throw instance; } on lib.Const {} /// catch_check: continued | |
| 45 }, (e) => e is TypeError); /// catch_check: continued | |
| 46 int i = lib.C.staticMethod(); /// static_method: ok | |
| 47 }); | |
| 48 } | |
| 49 | |
| 50 lib.C a9 = null; /// type_annotation_top_level: static type warning | |
| OLD | NEW |