Skip to content

Commit 267b8ef

Browse files
pqCommit Queue
authored and
Commit Queue
committed
[wildcards] test wildcard params in overrides
See: #55680 Change-Id: I7893a5e9b2ff91d50eb1a997206f958705f81e14 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375721 Commit-Queue: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 1c06d66 commit 267b8ef

File tree

4 files changed

+65
-3
lines changed

4 files changed

+65
-3
lines changed

pkg/analyzer/doc/process/new_language_feature.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The features are listed roughly in dependency order.
4545
- [ ] Constant evaluation
4646
- [ ] Index and search
4747
- [ ] Warnings (annotation-based, unused\*, strict-mode-based, a few others)
48-
- [ ] `InheritanceOverrideVerifier` (report errors and warnings related to overrides)
48+
- [ ] `OverrideVerifier` and `InheritanceOverrideVerifier` (report errors and warnings related to overrides)
4949
- [ ] `ErrorVerifier` (report other errors and warnings)
5050
- [ ] `FfiVerifier` (report errors and warnings related to FFI)
5151
- [ ] Unused elements warnings

pkg/analyzer/lib/src/error/inheritance_override.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,8 +850,8 @@ class _ClassVerifier {
850850
if (conflict is GetterMethodConflict) {
851851
// Members that participate in inheritance are always enclosed in named
852852
// elements so it is safe to assume that
853-
// `conflict.getter.enclosingElement3.name` and
854-
// `conflict.method.enclosingElement3.name` are both non-`null`.
853+
// `conflict.getter.enclosingElement.name` and
854+
// `conflict.method.enclosingElement.name` are both non-`null`.
855855
reporter.atToken(
856856
token,
857857
CompileTimeErrorCode.INCONSISTENT_INHERITANCE_GETTER_AND_METHOD,

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,41 @@ class B extends A {}
369369
''');
370370
}
371371

372+
test_method_overriddenWithMethod_wildcardParams() async {
373+
await assertNoErrorsInCode('''
374+
import 'package:meta/meta.dart';
375+
376+
class C {
377+
@mustBeOverridden
378+
void m(int x) {}
379+
}
380+
381+
class A extends C {
382+
@override
383+
void m(int _) {}
384+
}
385+
''');
386+
}
387+
388+
test_method_overriddenWithMethod_wildcardParams_preWildcards() async {
389+
await assertNoErrorsInCode('''
390+
// @dart = 3.4
391+
// (pre wildcard-variables)
392+
393+
import 'package:meta/meta.dart';
394+
395+
class C {
396+
@mustBeOverridden
397+
void m(int x) {}
398+
}
399+
400+
class A extends C {
401+
@override
402+
void m(int _) {}
403+
}
404+
''');
405+
}
406+
372407
test_method_sealedClassIsImplicitlyAbstract() async {
373408
await assertNoErrorsInCode('''
374409
import 'package:meta/meta.dart';

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,33 @@ class B extends A {
5252
}''');
5353
}
5454

55+
test_class_extends_wildcardParams() async {
56+
await assertNoErrorsInCode(r'''
57+
class A {
58+
void foo(int x) {}
59+
}
60+
61+
class B extends A {
62+
@override
63+
void foo(int _) {}
64+
}''');
65+
}
66+
67+
test_class_extends_wildcardParams_preWildCards() async {
68+
await assertNoErrorsInCode(r'''
69+
// @dart = 3.4
70+
// (pre wildcard-variables)
71+
72+
class A {
73+
void foo(int x) {}
74+
}
75+
76+
class B extends A {
77+
@override
78+
void foo(int _) {}
79+
}''');
80+
}
81+
5582
test_class_implements() async {
5683
await assertNoErrorsInCode(r'''
5784
class A {

0 commit comments

Comments
 (0)