OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // Verify that the ?. operator cannot be used with "super". | 5 // Verify that the ?. operator cannot be used with "super". |
6 | 6 |
7 class B { | 7 class B { |
8 B(); | 8 B(); |
9 B.namedConstructor(); | 9 B.namedConstructor(); |
10 var field = 1; | 10 var field = 1; |
11 method() => 1; | 11 method() => 1; |
12 } | 12 } |
13 | 13 |
14 class C extends B { | 14 class C extends B { |
15 C() | 15 C() |
16 : super?.namedConstructor() /// 01: compile-time error | 16 : super?.namedConstructor() //# 01: compile-time error |
17 ; | 17 ; |
18 | 18 |
19 test() { | 19 test() { |
20 super?.field = 1; /// 02: compile-time error | 20 super?.field = 1; //# 02: compile-time error |
21 super?.field += 1; /// 03: compile-time error | 21 super?.field += 1; //# 03: compile-time error |
22 super?.field ??= 1; /// 04: compile-time error | 22 super?.field ??= 1; //# 04: compile-time error |
23 super?.field; /// 05: compile-time error | 23 super?.field; //# 05: compile-time error |
24 1 * super?.field; /// 06: compile-time error | 24 1 * super?.field; //# 06: compile-time error |
25 -super?.field; /// 07: compile-time error | 25 -super?.field; //# 07: compile-time error |
26 ~super?.field; /// 08: compile-time error | 26 ~super?.field; //# 08: compile-time error |
27 !super?.field; /// 09: compile-time error | 27 !super?.field; //# 09: compile-time error |
28 --super?.field; /// 10: compile-time error | 28 --super?.field; //# 10: compile-time error |
29 ++super?.field; /// 11: compile-time error | 29 ++super?.field; //# 11: compile-time error |
30 super?.method(); /// 12: compile-time error | 30 super?.method(); //# 12: compile-time error |
31 1 * super?.method(); /// 13: compile-time error | 31 1 * super?.method(); //# 13: compile-time error |
32 -super?.method(); /// 14: compile-time error | 32 -super?.method(); //# 14: compile-time error |
33 ~super?.method(); /// 15: compile-time error | 33 ~super?.method(); //# 15: compile-time error |
34 !super?.method(); /// 16: compile-time error | 34 !super?.method(); //# 16: compile-time error |
35 --super?.method(); /// 17: compile-time error | 35 --super?.method(); //# 17: compile-time error |
36 ++super?.method(); /// 18: compile-time error | 36 ++super?.method(); //# 18: compile-time error |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 main() { | 40 main() { |
41 new C().test(); | 41 new C().test(); |
42 } | 42 } |
OLD | NEW |