Skip to content

Commit 82a59fe

Browse files
stereotype441Commit Queue
authored andcommitted
[analyzer] Introduce experimental_member_use warning.
In a follow-up CL, I will add logic to report this warning if reference is made to an element annotated with `@experimental`. In order to do that without causing trybot failures, I will need a preparatory CL that add some analysis_options directives to ignore the new warning in places where it's expected. But the analyzer contains logic to warn if an unknown diargnostic code is referenced from an analysis_options file. So to avoid that preparatory CL causing trybot failures, I need to first add the warning code itself, which is what this CL does. Change-Id: I6a6a69642c1487bf765b49f0e73c6e8468615fcc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451341 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Paul Berry <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 305189e commit 82a59fe

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3560,6 +3560,8 @@ WarningCode.EQUAL_KEYS_IN_MAP:
35603560
status: noFix
35613561
notes: |-
35623562
Fix depends on user's intent, which can't be known.
3563+
WarningCode.EXPERIMENTAL_MEMBER_USE:
3564+
status: needsEvaluation
35633565
WarningCode.INFERENCE_FAILURE_ON_COLLECTION_LITERAL:
35643566
status: noFix
35653567
WarningCode.INFERENCE_FAILURE_ON_FUNCTION_INVOCATION:

pkg/analyzer/lib/src/diagnostic/diagnostic_code_values.g.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,7 @@ const List<DiagnosticCode> diagnosticCodeValues = [
10141014
WarningCode.duplicateShownName,
10151015
WarningCode.equalElementsInSet,
10161016
WarningCode.equalKeysInMap,
1017+
WarningCode.experimentalMemberUse,
10171018
WarningCode.inferenceFailureOnCollectionLiteral,
10181019
WarningCode.inferenceFailureOnFunctionInvocation,
10191020
WarningCode.inferenceFailureOnFunctionReturnType,

pkg/analyzer/lib/src/error/codes.g.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11220,6 +11220,18 @@ class WarningCode extends DiagnosticCodeWithExpectedTypes {
1122011220
expectedTypes: [],
1122111221
);
1122211222

11223+
/// Parameters:
11224+
/// String member: the name of the member
11225+
static const WarningTemplate<
11226+
LocatableDiagnostic Function({required String member})
11227+
>
11228+
experimentalMemberUse = WarningTemplate(
11229+
'EXPERIMENTAL_MEMBER_USE',
11230+
"'{0}' is experimental and could be removed or changed at any time.",
11231+
withArguments: _withArgumentsExperimentalMemberUse,
11232+
expectedTypes: [ExpectedType.string],
11233+
);
11234+
1122311235
/// When "strict-inference" is enabled, collection literal types must be
1122411236
/// inferred via the context type, or have type arguments.
1122511237
///
@@ -13110,6 +13122,12 @@ class WarningCode extends DiagnosticCodeWithExpectedTypes {
1311013122
return LocatableDiagnosticImpl(duplicateIgnore, [p0]);
1311113123
}
1311213124

13125+
static LocatableDiagnostic _withArgumentsExperimentalMemberUse({
13126+
required String member,
13127+
}) {
13128+
return LocatableDiagnosticImpl(experimentalMemberUse, [member]);
13129+
}
13130+
1311313131
static LocatableDiagnostic _withArgumentsInferenceFailureOnCollectionLiteral({
1311413132
required String p0,
1311513133
}) {

pkg/analyzer/messages.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24790,6 +24790,11 @@ WarningCode:
2479024790
Note that literal maps preserve the order of their entries, so the choice
2479124791
of which entry to remove might affect the order in which the keys and
2479224792
values are returned by an iterator.
24793+
EXPERIMENTAL_MEMBER_USE:
24794+
parameters:
24795+
String member: the name of the member
24796+
problemMessage: "'#member' is experimental and could be removed or changed at any time."
24797+
hasPublishedDocs: false
2479324798
INFERENCE_FAILURE_ON_COLLECTION_LITERAL:
2479424799
parameters:
2479524800
String p0: the name of the collection

0 commit comments

Comments
 (0)