| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
| 6 import 'package:async_helper/async_helper.dart'; | 6 import 'package:async_helper/async_helper.dart'; |
| 7 | 7 |
| 8 import "deferred_constraints_lib.dart" deferred as lib; | 8 import "deferred_constraints_lib.dart" deferred as lib; |
| 9 import "deferred_constraints_lib.dart" as lib2; /// type_annotation_non_deferred
: ok | 9 import "deferred_constraints_lib.dart" as lib2; //# type_annotation_non_deferred
: ok |
| 10 | 10 |
| 11 class F {} | 11 class F {} |
| 12 class G2<T> {} | 12 class G2<T> {} |
| 13 | 13 |
| 14 main() { | 14 main() { |
| 15 lib.C a = null; /// type_annotation_null: compile-time error | 15 lib.C a = null; //# type_annotation_null: compile-time error |
| 16 Expect.throws(() { /// new_before_load: compile-time error | 16 Expect.throws(() { //# new_before_load: compile-time error |
| 17 lib.C a = new lib.C(); /// new_before_load: continued | 17 lib.C a = new lib.C(); //# new_before_load: continued |
| 18 }, (e) => e is Error); /// new_before_load: continued | 18 }, (e) => e is Error); //# new_before_load: continued |
| 19 | 19 |
| 20 // In this case we do not defer C. | 20 // In this case we do not defer C. |
| 21 lib2.C a1 = new lib2.C(); /// type_annotation_non_deferred: continued | 21 lib2.C a1 = new lib2.C(); //# type_annotation_non_deferred: continued |
| 22 asyncStart(); | 22 asyncStart(); |
| 23 lib.loadLibrary().then((_) { | 23 lib.loadLibrary().then((_) { |
| 24 lib.C a2 = new lib.C(); /// type_annotation1: dynamic type error, compile-ti
me error | 24 lib.C a2 = new lib.C(); //# type_annotation1: dynamic type error, compile-ti
me error |
| 25 lib.G<F> a3 = new lib.G<F>(); /// type_annotation_generic1: dynamic type err
or, compile-time error | 25 lib.G<F> a3 = new lib.G<F>(); //# type_annotation_generic1: dynamic type err
or, compile-time error |
| 26 G2<lib.C> a4 = new G2(); /// type_annotation_generic2: compile-time error | 26 G2<lib.C> a4 = new G2(); //# type_annotation_generic2: compile-time error |
| 27 G2<lib.C> a5 = new G2<lib.C>(); /// type_annotation_generic3: compile-time e
rror | 27 G2<lib.C> a5 = new G2<lib.C>(); //# type_annotation_generic3: compile-time e
rror |
| 28 lib.G<lib.C> a = new lib.G<lib.C>(); /// type_annotation_generic4: dynamic t
ype error, compile-time error | 28 lib.G<lib.C> a = new lib.G<lib.C>(); //# type_annotation_generic4: dynamic t
ype error, compile-time error |
| 29 var a6 = new lib.C(); /// new: ok | 29 var a6 = new lib.C(); //# new: ok |
| 30 var g1 = new lib.G<F>(); /// new_generic1: ok | 30 var g1 = new lib.G<F>(); //# new_generic1: ok |
| 31 // new G2<lib.C>() does not give a dynamic type error because a malformed | 31 // new G2<lib.C>() does not give a dynamic type error because a malformed |
| 32 // type used as type-parameter is treated as dynamic. | 32 // type used as type-parameter is treated as dynamic. |
| 33 var g2 = new G2<lib.C>(); /// new_generic2: compile-time error | 33 var g2 = new G2<lib.C>(); //# new_generic2: compile-time error |
| 34 var g3 = new lib.G<lib.C>(); /// new_generic3: compile-time error | 34 var g3 = new lib.G<lib.C>(); //# new_generic3: compile-time error |
| 35 var instance = lib.constantInstance; | 35 var instance = lib.constantInstance; |
| 36 Expect.throws(() { /// is_check: compile-time error | 36 Expect.throws(() { //# is_check: compile-time error |
| 37 bool a7 = instance is lib.Const; /// is_check: continued | 37 bool a7 = instance is lib.Const; //# is_check: continued |
| 38 }, (e) => e is TypeError); /// is_check: continued | 38 }, (e) => e is TypeError); //# is_check: continued |
| 39 Expect.throws(() { /// as_operation: compile-time error | 39 Expect.throws(() { //# as_operation: compile-time error |
| 40 instance as lib.Const; /// as_operation: continued | 40 instance as lib.Const; //# as_operation: continued |
| 41 }, (e) => e is TypeError); /// as_operation: continued | 41 }, (e) => e is TypeError); //# as_operation: continued |
| 42 Expect.throws(() { /// catch_check: compile-time error | 42 Expect.throws(() { //# catch_check: compile-time error |
| 43 try { throw instance; } on lib.Const {} /// catch_check: continued | 43 try { throw instance; } on lib.Const {} //# catch_check: continued |
| 44 }, (e) => e is TypeError); /// catch_check: continued | 44 }, (e) => e is TypeError); //# catch_check: continued |
| 45 int i = lib.C.staticMethod(); /// static_method: ok | 45 int i = lib.C.staticMethod(); //# static_method: ok |
| 46 asyncEnd(); | 46 asyncEnd(); |
| 47 }); | 47 }); |
| 48 } | 48 } |
| 49 | 49 |
| 50 lib.C a9 = null; /// type_annotation_top_level: compile-time error | 50 lib.C a9 = null; //# type_annotation_top_level: compile-time error |
| OLD | NEW |