[DAS] Adds priority tests for CHANGE_TYPE_ANNOTATION fix

This also changes the priority of some fixes:
- `ADD_AWAIT` and `ADD_AWAIT_MULTI` are now one point higher than standard
- `ADD_EXPLICIT_CAST` and `ADD_EXPLICIT_CAST_MULTI` are now one point lower than standard

This ensures that when these fixes are available, `ADD_AWAIT` is preferred over `CHANGE_TYPE_ANNOTATION` and lastly `ADD_EXPLICIT_CAST`.

Fixes: https://github.com/dart-lang/sdk/issues/61421
Change-Id: I89cf9d9dd386773ebcb998207213cf6e636a060e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448643
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
This commit is contained in:
FMorschel
2025-09-22 16:16:10 -07:00
committed by Commit Queue
parent 74ef6d1740
commit befbc718bb
3 changed files with 21 additions and 10 deletions
@@ -37,9 +37,6 @@ class AddAwait extends ResolvedCorrectionProducer {
@override
FixKind get fixKind => DartFixKind.ADD_AWAIT;
@override
FixKind get multiFixKind => DartFixKind.ADD_AWAIT_MULTI;
FunctionBody? get _functionBodyIfNotAsync {
var body = node.thisOrAncestorOfType<FunctionBody>();
if (body != null && !body.isAsynchronous && body.star == null) {
@@ -39,14 +39,9 @@ abstract final class DartFixKind {
);
static const ADD_AWAIT = FixKind(
'dart.fix.add.await',
DartFixKindPriority.standard,
DartFixKindPriority.standard + 1,
"Add 'await' keyword",
);
static const ADD_AWAIT_MULTI = FixKind(
'dart.fix.add.await.multi',
DartFixKindPriority.inFile,
"Add 'await's everywhere in file",
);
static const ADD_CALL_SUPER = FixKind(
'dart.fix.add.callSuper',
DartFixKindPriority.standard,
@@ -149,7 +144,7 @@ abstract final class DartFixKind {
);
static const ADD_EXPLICIT_CAST = FixKind(
'dart.fix.add.explicitCast',
DartFixKindPriority.standard,
DartFixKindPriority.standard - 1,
'Add cast',
);
static const ADD_EXPLICIT_CAST_MULTI = FixKind(
@@ -10,10 +10,29 @@ import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(ChangeTypeAnnotationPriorityTest);
defineReflectiveTests(ChangeTypeAnnotationTest);
});
}
@reflectiveTest
class ChangeTypeAnnotationPriorityTest extends FixPriorityTest {
Future<void> test_futureType() async {
await resolveTestCode('''
Future<int> foo() async => 0;
Future<void> bar() async {
int _ = foo();
}
''');
await assertFixPriorityOrder([
DartFixKind.ADD_AWAIT,
DartFixKind.CHANGE_TYPE_ANNOTATION,
DartFixKind.ADD_EXPLICIT_CAST,
]);
}
}
@reflectiveTest
class ChangeTypeAnnotationTest extends FixProcessorTest {
@override