dart-sdk/tests/language/extension_methods/issue_45551_error_test.dart
Paul Berry c739b324a6 Make language tests for issue #45551
Previously, the "why not promoted" test cases sort of exercised this
bug, but in an unclear way that wasn't really related to the "why not
promoted" functionality.  Better to have a separate test for it.

Bug: https://github.com/dart-lang/sdk/issues/45551
Change-Id: Idd44596f021eb91679a019f9f56da1661363d0d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193829
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-04-06 13:01:47 +00:00

23 lines
610 B
Dart

// 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.
// This test illustrates the error scenario described in
// https://github.com/dart-lang/sdk/issues/45551
class C {}
extension on C {
void Function() get call => () {};
}
test(C c) {
c();
//^
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] Cannot invoke an instance of 'C' because it declares 'call' to be something other than a method.
}
main() {}