blob: 0a602afa02e30b9e116229256774e23cb9887278 [file] [log] [blame]
// Copyright (c) 2021, 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 promotable via initialization given
* variable model VM if x is a local variable (not a formal parameter) and:
*
* VM = VariableModel(declared, promoted, tested, assigned, unassigned,
* captured)
* and captured is false
* and promoted is empty
* and x is declared with no explicit type and no initializer
* and assigned is false and unassigned is true
*
* @description Checks that a variable is promotable to the type T if all
* requirements above are met.
*
* @author sgrekhov@unipro.ru
* @issue 41669
*/
// Requirements=nnbd-weak
import "../../../../Utils/expect.dart";
class T {
int foo() => 42;
}
main() {
var x;
x = new T();
x.foo();
Expect.throws(() {x.bar();}, (e) => e is NoSuchMethodError); // Check that x is dynamic
}