Skip to content

Commit c739b32

Browse files
stereotype441commit-bot@chromium.org
authored andcommitted
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: #45551 Change-Id: Idd44596f021eb91679a019f9f56da1661363d0d8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193829 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent cf7587a commit c739b32

File tree

3 files changed

+44
-13
lines changed

3 files changed

+44
-13
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// This test illustrates the error scenario described in
6+
// https://github.com/dart-lang/sdk/issues/45551
7+
8+
class C {}
9+
10+
extension on C {
11+
void Function() get call => () {};
12+
}
13+
14+
test(C c) {
15+
c();
16+
//^
17+
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
18+
// ^
19+
// [cfe] Cannot invoke an instance of 'C' because it declares 'call' to be something other than a method.
20+
}
21+
22+
main() {}

tests/language/why_not_promoted/nullable_expression_call_error_test.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,32 +79,19 @@ instance_getter_invocation(C6 c) {
7979
}
8080

8181
class C8 {
82-
C9? ok;
8382
C10? bad;
8483
// ^^^
8584
// [context 4] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
8685
// [context 10] 'bad' refers to a property so it couldn't be promoted.
8786
}
8887

89-
class C9 {}
90-
9188
class C10 {}
9289

93-
extension on C9? {
94-
void Function() get call => () {};
95-
}
96-
9790
extension on C10 {
9891
void Function() get call => () {};
9992
}
10093

10194
extension_invocation_getter(C8 c) {
102-
if (c.ok == null) return;
103-
// Note: the analyzer produces an extraneous error on the line below due to
104-
// https://github.com/dart-lang/sdk/issues/45551
105-
c.ok();
106-
//^^^^
107-
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
10895
if (c.bad == null) return;
10996
c.bad();
11097
//^^^^^
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// This test illustrates the error scenario described in
6+
// https://github.com/dart-lang/sdk/issues/45551
7+
8+
class C {}
9+
10+
extension on C {
11+
void Function() get call => () {};
12+
}
13+
14+
test(C c) {
15+
c();
16+
//^
17+
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
18+
// ^
19+
// [cfe] Cannot invoke an instance of 'C' because it declares 'call' to be something other than a method.
20+
}
21+
22+
main() {}

0 commit comments

Comments
 (0)