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 // SharedOptions=--enable-null-aware-operators | |
9 | |
10 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
11 | 9 |
12 class C { | 10 class C { |
13 int v; | 11 int v; |
14 C(this.v); | 12 C(this.v); |
15 static var staticField; | 13 static var staticField; |
16 } | 14 } |
17 | 15 |
18 class D { | 16 class D { |
19 E v; | 17 E v; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 { D d = new D(new E()); H h = ++d?.v; Expect.identical(d.v, h); } /// 12: stat
ic type warning | 63 { D d = new D(new E()); H h = ++d?.v; Expect.identical(d.v, h); } /// 12: stat
ic type warning |
66 | 64 |
67 // --e1?.v is equivalent to e1?.v += 1. | 65 // --e1?.v is equivalent to e1?.v += 1. |
68 Expect.equals(null, --nullC()?.v); /// 13: ok | 66 Expect.equals(null, --nullC()?.v); /// 13: ok |
69 { C c = new C(1); Expect.equals(0, --c?.v); Expect.equals(0, c.v); } /// 14: o
k | 67 { C c = new C(1); Expect.equals(0, --c?.v); Expect.equals(0, c.v); } /// 14: o
k |
70 | 68 |
71 // The static type of --e1?.v is the same as the static type of e1.v - 1. | 69 // The static type of --e1?.v is the same as the static type of e1.v - 1. |
72 { D d = new D(new E()); F f = --d?.v; Expect.identical(d.v, f); } /// 15: ok | 70 { D d = new D(new E()); F f = --d?.v; Expect.identical(d.v, f); } /// 15: ok |
73 { D d = new D(new E()); H h = --d?.v; Expect.identical(d.v, h); } /// 16: stat
ic type warning | 71 { D d = new D(new E()); H h = --d?.v; Expect.identical(d.v, h); } /// 16: stat
ic type warning |
74 } | 72 } |
OLD | NEW |