Skip to content

Commit a9f288a

Browse files
pqCommit Queue
authored andcommitted
[diagnostics] fix removed_lint reporting
Bug: #59869 Change-Id: I0b69f4380e0b556f6612294a3c6485cebd5e56fd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407621 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent fb0cac7 commit a9f288a

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

pkg/analyzer/lib/src/lint/options_rule_validator.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,17 @@ class LinterRuleOptionsValidator extends OptionsValidator {
4040
bool isDeprecatedInCurrentSdk(DeprecatedState state) =>
4141
currentSdkAllows(state.since);
4242

43-
bool isRemovedInCurrentSdk(State state) {
43+
bool isRemovedInCurrentOrEarlierSdk(State state) {
4444
if (state is! RemovedState) return false;
45-
return currentSdkAllows(state.since);
45+
46+
var removed = state.since;
47+
// No "since" applies to all SDKs.
48+
if (removed == null) return true;
49+
50+
return switch (sdkVersionConstraint) {
51+
VersionRange(min: var min?) => removed <= min,
52+
_ => false
53+
};
4654
}
4755

4856
@override
@@ -116,7 +124,7 @@ class LinterRuleOptionsValidator extends OptionsValidator {
116124
arguments: [value],
117125
);
118126
}
119-
} else if (isRemovedInCurrentSdk(state)) {
127+
} else if (isRemovedInCurrentOrEarlierSdk(state)) {
120128
var since = state.since.toString();
121129
var replacedBy = (state as RemovedState).replacedBy;
122130
if (replacedBy != null) {

pkg/analyzer/test/src/options/options_rule_validator_test.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,19 @@ linter:
200200
);
201201
}
202202

203+
/// https://github.com/dart-lang/sdk/issues/59869
204+
test_removed_rule_previousSdk() {
205+
assertErrors(
206+
'''
207+
linter:
208+
rules:
209+
- removed_in_2_12_lint
210+
''',
211+
[AnalysisOptionsWarningCode.REMOVED_LINT],
212+
sdk: dart3_3,
213+
);
214+
}
215+
203216
test_replaced_rule() {
204217
assertErrors(
205218
'''

0 commit comments

Comments
 (0)