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 semantics of the ?. operator when it appears on the LHS of an | 5 // Verify semantics of the ?. operator when it appears on the LHS of an |
6 // assignment. | 6 // assignment. |
7 | 7 |
8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
9 import "conditional_access_helper.dart" as h; | 9 import "conditional_access_helper.dart" as h; |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 static int staticInt; | 22 static int staticInt; |
23 } | 23 } |
24 | 24 |
25 class D { | 25 class D { |
26 E v; | 26 E v; |
27 D(this.v); | 27 D(this.v); |
28 static E staticE; | 28 static E staticE; |
29 } | 29 } |
30 | 30 |
31 class E { | 31 class E { |
32 G operator +(int i) => new I(); | 32 G operator+(int i) => new I(); |
33 } | 33 } |
34 | 34 |
35 class F {} | 35 class F {} |
36 | 36 |
37 class G extends E implements F {} | 37 class G extends E implements F {} |
38 | 38 |
39 class H {} | 39 class H {} |
40 | 40 |
41 class I extends G implements H {} | 41 class I extends G implements H {} |
42 | 42 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 { h.D.staticE = new h.E(); h.F f = (h.D?.staticE += h.nullC()); Expect.identic
al(h.D.staticE, f); } //# 33: static type warning | 91 { h.D.staticE = new h.E(); h.F f = (h.D?.staticE += h.nullC()); Expect.identic
al(h.D.staticE, f); } //# 33: static type warning |
92 { D.staticE = new E(); H h = (D?.staticE += 1); Expect.identical(D.staticE, h)
; } //# 34: static type warning | 92 { D.staticE = new E(); H h = (D?.staticE += 1); Expect.identical(D.staticE, h)
; } //# 34: static type warning |
93 { h.D.staticE = new h.E(); h.H hh = (h.D?.staticE += 1); Expect.identical(h.D.
staticE, hh); } //# 35: static type warning | 93 { h.D.staticE = new h.E(); h.H hh = (h.D?.staticE += 1); Expect.identical(h.D.
staticE, hh); } //# 35: static type warning |
94 | 94 |
95 // '?.' cannot be used to assign to toplevel properties in libraries imported | 95 // '?.' cannot be used to assign to toplevel properties in libraries imported |
96 // via prefix. | 96 // via prefix. |
97 h?.topLevelVar = null; //# 20: compile-time error | 97 h?.topLevelVar = null; //# 20: compile-time error |
98 h?.topLevelVar += null; //# 21: compile-time error | 98 h?.topLevelVar += null; //# 21: compile-time error |
99 h?.topLevelVar ??= null; //# 22: compile-time error | 99 h?.topLevelVar ??= null; //# 22: compile-time error |
100 } | 100 } |
OLD | NEW |