| // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| |
| /// @assertion We say that a variable x is demotable via assignment of an |
| /// expression of type T given variable model VM if |
| /// |
| /// VM = VariableModel(declared, promoted, tested, assigned, unassigned, |
| /// captured) |
| /// and captured is false |
| /// and declared::promoted contains a type S such that T is S or T is NonNull(S) |
| /// |
| /// @description Checks that a variable is demotable to the type T if all |
| /// requirements above are met. |
| /// |
| /// @author sgrekhov@unipro.ru |
| |
| |
| class A {} |
| class B extends A { |
| int bar() => 42; |
| } |
| class T extends B { |
| int foo() => 42; |
| } |
| |
| main() { |
| A x = new T(); |
| if (x is B) { |
| if (x is T) { |
| x.foo(); |
| x = new B(); |
| x.bar(); |
| x.foo(); |
| // ^^^ |
| // [analyzer] unspecified |
| // [cfe] unspecified |
| } |
| } |
| } |