Skip to content

Commit ac68903

Browse files
FMorschelCommit Queue
authored andcommitted
[analyzer] Fixes unqualified_reference_to_non_local_static_member case for static Object method tear-offs
Fixes: #61276 Change-Id: I51010e118894151cbe8bbe9fd989eb7487a08251 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444444 Auto-Submit: Felipe Morschel <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]>
1 parent 9caaa82 commit ac68903

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

pkg/analyzer/lib/src/generated/error_verifier.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5611,9 +5611,11 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
56115611
if (element is ExecutableElement && !element.isStatic) {
56125612
return;
56135613
}
5614-
if (element is MethodElement) {
5614+
if (name.parent case MethodInvocation(
5615+
:var methodName,
5616+
) when name == methodName) {
56155617
// Invalid methods are reported in
5616-
// [MethodInvocationResolver._resolveReceiverNull].
5618+
// [MethodInvocationResolver._reportInstanceAccessToStaticMember].
56175619
return;
56185620
}
56195621
if (_enclosingExtension != null) {

pkg/analyzer/test/src/diagnostics/unqualified_reference_to_non_local_static_member_test.dart

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@ class B extends A {
3535
);
3636
}
3737

38+
test_getter_invoke() async {
39+
await assertErrorsInCode(
40+
'''
41+
class A {
42+
static void Function() get a => () {};
43+
}
44+
45+
class B extends A {
46+
void b() {
47+
a();
48+
}
49+
}
50+
''',
51+
[error(_errorCode, 91, 1)],
52+
);
53+
}
54+
3855
test_getter_invokeTarget() async {
3956
await assertErrorsInCode(
4057
r'''
@@ -68,6 +85,22 @@ class B extends A {
6885
);
6986
}
7087

88+
test_methodTearoff_noTypeArguments() async {
89+
await assertErrorsInCode(
90+
'''
91+
class A {
92+
static void a() {}
93+
}
94+
class B extends A {
95+
void b() {
96+
a;
97+
}
98+
}
99+
''',
100+
[error(_errorCode, 70, 1)],
101+
);
102+
}
103+
71104
test_readWrite() async {
72105
await assertErrorsInCode(
73106
r'''

0 commit comments

Comments
 (0)