Files
sdk/tests/language/nnbd/static_errors/local_function_inference.dart
T
Leaf Petersen db36f1190f [Language] Various NNBD Tests.
Add a variety of small nnbd tests covering the specification
changes/clarifications landed in
https://github.com/dart-lang/language/pull/1003 .

Change-Id: I0716f14652128323bf103df154efb5bf978091d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150160
Commit-Queue: Leaf Petersen <leafp@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2020-06-05 23:53:20 +00:00

30 lines
743 B
Dart

// 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.
/// Test that the type of a local function is an error if local function type
/// inference requires the type of the function being inferred.
void main() {
f() {
return 3;
}
f().arglebargle;
// ^^^^^^^^^^^
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
// [cfe] The getter 'arglebargle' isn't defined for the class 'int'.
f().isEven; // Inferred type is int
g() {
if (f() == 3) {
return g();
} else {
return 3;
}
}
// ^
// [analyzer] undefined
// [cfe] undefined
}