OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, 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 /*@testedFeatures=inference*/ |
| 6 library test; |
| 7 |
| 8 abstract class A { |
| 9 int get x; |
| 10 } |
| 11 |
| 12 abstract class B { |
| 13 int get x; |
| 14 } |
| 15 |
| 16 abstract class C { |
| 17 num get x; |
| 18 } |
| 19 |
| 20 abstract class D { |
| 21 double get x; |
| 22 } |
| 23 |
| 24 // Superclasses have a consistent type for `x` so inferrence succeeds. |
| 25 class E extends A implements B { |
| 26 var /*@topType=int*/ x; |
| 27 } |
| 28 |
| 29 // Superclasses don't have a consistent type for `x` so inference fails, even if |
| 30 // the types are related. |
| 31 class F extends A implements C { |
| 32 var /*@topType=dynamic*/ x; |
| 33 } |
| 34 |
| 35 class G extends A implements D { |
| 36 var /*@topType=dynamic*/ x; |
| 37 } |
| 38 |
| 39 class H extends C implements D { |
| 40 var /*@topType=dynamic*/ x; |
| 41 } |
| 42 |
| 43 main() {} |
OLD | NEW |