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 // Regression test for dart2js: we incorrectly modeled `super.x = rhs` as a |
| 6 // call and not an assignment, so the type of the expression was incorrectly |
| 7 // assumed to be the return type of the setter rather than the type of the rhs. |
| 8 import 'package:expect/expect.dart'; |
| 9 |
| 10 abstract class A { |
| 11 set x(v) {} |
| 12 set z(v) {} |
| 13 set y(v) { return 'hi';} |
| 14 } |
| 15 |
| 16 class S extends A { |
| 17 var _x; // was bad: inferred as null, than [null | int] |
| 18 var _y = ''; // was bad: inferred as String, rather than [String | int] |
| 19 var _z; // was ok : inferred as [null | int] |
| 20 |
| 21 set x(v) { |
| 22 _x = super.x = v; |
| 23 } |
| 24 |
| 25 set z(v) { |
| 26 super.z = v; |
| 27 _z = v; |
| 28 } |
| 29 |
| 30 set y(v) { |
| 31 _y = super.y = v; |
| 32 } |
| 33 |
| 34 get isXNull => _x == null; |
| 35 get isZNull => _z == null; |
| 36 } |
| 37 |
| 38 main() { |
| 39 var s = new S() |
| 40 ..x = 2 |
| 41 ..y = 2 |
| 42 ..z = 2; |
| 43 Expect.equals(false, s.isXNull); // was incorrectly optimized to 'true' |
| 44 Expect.equals(false, s._y is String); // was incorrectly optimized to 'true' |
| 45 Expect.equals(false, s.isZNull); // prints false |
| 46 } |
OLD | NEW |