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 in a postincrement or | 5 // Verify semantics of the ?. operator when it appears in a postincrement or |
6 // preincrement expression (or a postdecrement or predecrement expression). | 6 // preincrement expression (or a postdecrement or predecrement expression). |
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 |
11 class C { | 11 class C { |
12 int v; | 12 int v; |
13 C(this.v); | 13 C(this.v); |
14 static int staticInt; | 14 static int staticInt; |
15 } | 15 } |
16 | 16 |
17 class D { | 17 class D { |
18 E v; | 18 E v; |
19 D(this.v); | 19 D(this.v); |
20 static E staticE; | 20 static E staticE; |
21 } | 21 } |
22 | 22 |
23 class E { | 23 class E { |
24 G operator +(int i) => new I(); | 24 G operator+(int i) => new I(); |
25 G operator -(int i) => new I(); | 25 G operator-(int i) => new I(); |
26 } | 26 } |
27 | 27 |
28 class F {} | 28 class F {} |
29 | 29 |
30 class G extends E implements F {} | 30 class G extends E implements F {} |
31 | 31 |
32 class H {} | 32 class H {} |
33 | 33 |
34 class I extends G implements H {} | 34 class I extends G implements H {} |
35 | 35 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 { h.C.staticInt = 1; Expect.equals(0, --h.C?.staticInt); Expect.equals(0, h.C.
staticInt); } //# 36: ok | 97 { h.C.staticInt = 1; Expect.equals(0, --h.C?.staticInt); Expect.equals(0, h.C.
staticInt); } //# 36: ok |
98 | 98 |
99 // The static type of --e1?.v is the same as the static type of e1.v - 1. | 99 // The static type of --e1?.v is the same as the static type of e1.v - 1. |
100 { D d = new D(new E()); F f = --d?.v; Expect.identical(d.v, f); } //# 15: ok | 100 { D d = new D(new E()); F f = --d?.v; Expect.identical(d.v, f); } //# 15: ok |
101 { D d = new D(new E()); H h = --d?.v; Expect.identical(d.v, h); } //# 16: stat
ic type warning | 101 { D d = new D(new E()); H h = --d?.v; Expect.identical(d.v, h); } //# 16: stat
ic type warning |
102 { D.staticE = new E(); F f = --D?.staticE; Expect.identical(D.staticE, f); } /
/# 37: ok | 102 { D.staticE = new E(); F f = --D?.staticE; Expect.identical(D.staticE, f); } /
/# 37: ok |
103 { h.D.staticE = new h.E(); h.F f = --h.D?.staticE; Expect.identical(h.D.static
E, f); } //# 38: ok | 103 { h.D.staticE = new h.E(); h.F f = --h.D?.staticE; Expect.identical(h.D.static
E, f); } //# 38: ok |
104 { D.staticE = new E(); H h = --D?.staticE; Expect.identical(D.staticE, h); } /
/# 39: static type warning | 104 { D.staticE = new E(); H h = --D?.staticE; Expect.identical(D.staticE, h); } /
/# 39: static type warning |
105 { h.D.staticE = new h.E(); h.H hh = --h.D?.staticE; Expect.identical(h.D.stati
cE, hh); } //# 40: static type warning | 105 { h.D.staticE = new h.E(); h.H hh = --h.D?.staticE; Expect.identical(h.D.stati
cE, hh); } //# 40: static type warning |
106 } | 106 } |
OLD | NEW |