| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013, 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 // Test handling of malformed types in constant expressions. |
| 6 |
| 7 use(x) {} |
| 8 |
| 9 class Class<T> implements Superclass { |
| 10 const Class(); |
| 11 const Class.named(); |
| 12 |
| 13 void test() { |
| 14 use(const []); |
| 15 use(const <Class>[]); |
| 16 use(const <Class<int>>[]); |
| 17 use(const <Class<Unresolved>>[]); /// 01: static type warning |
| 18 use(const <Unresolved>[]); /// 02: static type warning |
| 19 |
| 20 use(const {}); |
| 21 use(const <Class>{}); /// 03: static type warning |
| 22 use(const <String, Class>{}); |
| 23 use(const <String, Class<int>>{}); |
| 24 use(const <String, Class<Unresolved>>{}); /// 04: static type warning |
| 25 use(const <String, Unresolved>{}); /// 05: static type warning |
| 26 |
| 27 use(const Class()); |
| 28 use(const Class<int>()); |
| 29 use(const Class<Unresolved>()); /// 06: static type warning |
| 30 use(const Class<T>()); /// 07: compile-time error |
| 31 use(const Class<Class<T>>()); /// 08: compile-time error |
| 32 |
| 33 use(const Unresolved()); /// 09: compile-time error |
| 34 use(const Unresolved<int>()); /// 10: compile-time error |
| 35 use(const prefix.Unresolved()); /// 11: compile-time error |
| 36 use(const prefix.Unresolved<int>()); /// 12: compile-time error |
| 37 |
| 38 use(const Class.named()); |
| 39 use(const Class<int>.named()); |
| 40 use(const Class<Unresolved>.named()); /// 13: static type warning |
| 41 use(const Class<T>.named()); /// 14: compile-time error |
| 42 use(const Class<Class<T>>.named()); /// 15: compile-time error |
| 43 |
| 44 use(const Class.nonamed()); /// 16: compile-time error |
| 45 use(const Class<int>.nonamed()); /// 17: compile-time error |
| 46 use(const Class<Unresolved>.nonamed()); /// 18: compile-time error |
| 47 use(const Class<T>.nonamed()); /// 19: compile-time error |
| 48 use(const Class<Class<T>>.nonamed()); /// 20: compile-time error |
| 49 |
| 50 use(const Unresolved.named()); /// 21: compile-time error |
| 51 use(const Unresolved<int>.named()); /// 22: compile-time error |
| 52 } |
| 53 } |
| 54 |
| 55 class Superclass<T> { |
| 56 const factory Superclass() = Unresolved; /// 23: compile-time error |
| 57 const factory Superclass() = Unresolved<int>; /// 24: compile-time error |
| 58 const factory Superclass() = Unresolved.named; /// 25: compile-time error |
| 59 const factory Superclass() = Unresolved<int>.named; /// 26: compile-time error |
| 60 |
| 61 const factory Superclass() = prefix.Unresolved; /// 27: compile-time error |
| 62 const factory Superclass() = prefix.Unresolved<int>; /// 28: compile-time erro
r |
| 63 const factory Superclass() = prefix.Unresolved.named; /// 29: compile-time err
or |
| 64 const factory Superclass() = prefix.Unresolved<int>.named; /// 30: compile-tim
e error |
| 65 |
| 66 const factory Superclass() = Class; /// 31: ok |
| 67 const factory Superclass() = Class<int>; /// 32: ok |
| 68 const factory Superclass() = Class<T>; /// 33: ok |
| 69 const factory Superclass() = Class<Class<T>>; /// 34: ok |
| 70 const factory Superclass() = Class<Unresolved>; /// 35: static type warning |
| 71 |
| 72 const factory Superclass() = Class.named; /// 36: ok |
| 73 const factory Superclass() = Class<int>.named; /// 37: ok |
| 74 const factory Superclass() = Class<T>.named; /// 38: ok |
| 75 const factory Superclass() = Class<Class<T>>.named; /// 39: ok |
| 76 const factory Superclass() = Class<Unresolved>.named; /// 40: static type warn
ing |
| 77 |
| 78 const factory Superclass() = T; /// 41: compile-time error |
| 79 } |
| 80 |
| 81 void main() { |
| 82 new Class().test(); |
| 83 new Superclass(); |
| 84 } |
| OLD | NEW |