| 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 import 'package:async_helper/async_helper.dart'; | |
| 8 | |
| 9 @lazy import "deferred_constraints_lib.dart" as lib; | |
| 10 import "deferred_constraints_lib.dart" as lib2; /// type_annotation_non_deferred
: ok | |
| 11 | |
| 12 const lazy = const DeferredLibrary('lib'); | |
| 13 | |
| 14 class F {} | |
| 15 class G2<T> {} | |
| 16 | |
| 17 void f({a: const lib.Const()}) {} /// const_default_argument: compile-time error | |
| 18 | |
| 19 @lib.Const() class H {} /// const_annotation: compile-time error | |
| 20 | |
| 21 void main() { | |
| 22 Expect.throws(() { /// type_annotation1: static type warning | |
| 23 lib.C a = new lib.C(); /// type_annotation1: continued | |
| 24 }, (e) => e is NoSuchMethodError); /// type_annotation1: continued | |
| 25 lib.C a = null; /// type_annotation_null: static type warning | |
| 26 | |
| 27 // In this case we do not defer C. | |
| 28 lib2.C a1 = new lib2.C(); /// type_annotation_non_deferred: continued | |
| 29 asyncStart(); | |
| 30 lazy.load().then((_) { | |
| 31 lib.C a2 = new lib.C(); /// type_annotation2: dynamic type error, static typ
e warning | |
| 32 lib.G<F> a3 = new lib.G<F>(); /// type_annotation_generic1: dynamic type err
or, static type warning | |
| 33 G2<lib.C> a4 = new G2(); /// type_annotation_generic2: static type warning | |
| 34 G2<lib.C> a5 = new G2<lib.C>(); /// type_annotation_generic3: static type wa
rning | |
| 35 lib.G<lib.C> a = new lib.G<lib.C>(); /// type_annotation_generic4: dynamic t
ype error, static type warning | |
| 36 var a6 = new lib.C(); /// new: ok | |
| 37 var g1 = new lib.G<F>(); /// new_generic1: ok | |
| 38 // new G2<lib.C>() does not give a dynamic type error because a malformed | |
| 39 // type used as type-parameter is treated as dynamic. | |
| 40 var g2 = new G2<lib.C>(); /// new_generic2: static type warning | |
| 41 var g3 = new lib.G<lib.C>(); /// new_generic3: static type warning | |
| 42 var instance = lib.constantInstance; | |
| 43 Expect.throws(() { /// is_check: static type warning | |
| 44 bool a7 = instance is lib.Const; /// is_check: continued | |
| 45 }, (e) => e is TypeError); /// is_check: continued | |
| 46 Expect.throws(() { /// as_operation: static type warning | |
| 47 instance as lib.Const; /// as_operation: continued | |
| 48 }, (e) => e is TypeError); /// as_operation: continued | |
| 49 Expect.throws(() { /// catch_check: static type warning | |
| 50 try { throw instance; } on lib.Const {} /// catch_check: continued | |
| 51 }, (e) => e is TypeError); /// catch_check: continued | |
| 52 int i = lib.C.staticMethod(); /// static_method: ok | |
| 53 var c1 = const lib.Const(); /// const: compile-time error | |
| 54 f(); /// const_default_argument: continued | |
| 55 var constInstance = lib.constantInstance; /// const_instance: ok | |
| 56 var h = new H(); /// const_annotation: continued | |
| 57 asyncEnd(); | |
| 58 }); | |
| 59 } | |
| 60 | |
| 61 lib.C a9 = null; /// type_annotation_top_level: static type warning | |
| OLD | NEW |