Files
sdk/pkg/front_end/testcases/nnbd/tearoff_from_nullable_receiver.dart
T
Dmitry Stefantsov 5e38b59740 [cfe] Don't allow implicit tear-offs of .call on nullable receivers
Closes #39710.

Bug: http://dartbug.com/39710
Change-Id: I3556fac1de1bd6874bbb052e05accebac9619c8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133982
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-01-31 09:39:21 +00:00

32 lines
1008 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.
class C {
int call() => 0;
}
functionContext(int Function() f) {}
nullableFunctionContext(int Function()? f) {}
foo<T extends C?>(C? c, T t, T? nt) {
functionContext(null as C?); // Error.
nullableFunctionContext(null as C?); // Error.
functionContext(c); // Error.
nullableFunctionContext(c); // Error.
functionContext(t); // Error.
nullableFunctionContext(t); // Error.
functionContext(nt); // Error.
nullableFunctionContext(nt); // Error.
}
bar<T extends C>(C c, T t) {
functionContext(c); // Shouldn't result in a compile-time error.
nullableFunctionContext(c); // Shouldn't result in a compile-time error.
functionContext(t); // Shouldn't result in a compile-time error.
nullableFunctionContext(t); // Shouldn't result in a compile-time error.
}
main() {}