| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 // Tests that a setter in a subclass does not shadow the getter in the | |
| 6 // superclass. | |
| 7 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 8 | 6 |
| 9 class A { | 7 class A { |
| 10 int _x = 42; | 8 int _x = 42; |
| 9 void set x(int val) { |
| 10 _x = val; |
| 11 } |
| 11 int get x => _x; | 12 int get x => _x; |
| 12 } | 13 } |
| 13 | 14 |
| 14 class B extends A { | 15 class B extends A { |
| 15 void set x(int val) { | 16 final x = 3; |
| 16 _x = val; | 17 // we can still get to the super property |
| 17 } | 18 int get y => _x; |
| 18 } | 19 } |
| 19 | 20 |
| 20 void main() { | 21 void main() { |
| 21 var b = new B(); | 22 var b = new B(); |
| 22 Expect.equals(42, b.x); | 23 Expect.equals(3, b.x); |
| 23 | 24 |
| 24 b.x = 21; | 25 b.x = 21; |
| 25 Expect.equals(21, b.x); | 26 Expect.equals(3, b.x); |
| 27 Expect.equals(21, b.y); |
| 26 } | 28 } |
| OLD | NEW |