mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:29:48 +00:00
9ad6cc49af
Change-Id: Ibfff039ddbba1e805c07f6eeec75d959c607d196 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233162 Reviewed-by: Erik Ernst <eernst@google.com> Reviewed-by: Lasse Nielsen <lrn@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
36 lines
1.3 KiB
Dart
36 lines
1.3 KiB
Dart
// Copyright (c) 2022, 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.
|
|
|
|
// This test exercises a corner case of implicit `.call` tearoffs that is
|
|
// easiest to see through its effect on erroneous code.
|
|
|
|
// NOTICE: This test checks the currently implemented behavior, even though the
|
|
// implemented behavior does not match the language specification. Until an
|
|
// official decision has been made about whether to change the implementation to
|
|
// match the specification, or vice versa, this regression test is intended to
|
|
// protect against inadvertent implementation changes.
|
|
|
|
import '../static_type_helper.dart';
|
|
|
|
class A {}
|
|
|
|
class C extends A {
|
|
void call() {}
|
|
}
|
|
|
|
class D extends A {
|
|
void call() {}
|
|
}
|
|
|
|
void testConditionalExpressionWithUnrelatedClasses(bool b, C c, D d) {
|
|
// Verify that `b ? c : d` is not interpreted as `(b ? c.call : d.call)` by
|
|
// confirming that it's an error to use it in a function context (because
|
|
// `b ? c : d` has static type `A`).
|
|
context<void Function()>(b ? c : d);
|
|
// ^^^^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
|
|
// ^
|
|
// [cfe] The argument type 'A' can't be assigned to the parameter type 'void Function()'.
|
|
}
|