mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 21:51:18 +00:00
REMOVE_UNNECESSARY_CAST
to be in bulk.
Fixes #47156 Change-Id: Id285c38b01124f8c404185a58c6b98bda87cefe1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212823 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
7b4714d355
commit
65db608726
|
@ -11,7 +11,7 @@ import 'package:analyzer_plugin/utilities/range_factory.dart';
|
|||
|
||||
class RemoveUnnecessaryCast extends CorrectionProducer {
|
||||
@override
|
||||
bool get canBeAppliedInBulk => false;
|
||||
bool get canBeAppliedInBulk => true;
|
||||
|
||||
@override
|
||||
bool get canBeAppliedToFile => true;
|
||||
|
|
|
@ -11,11 +11,34 @@ import 'fix_processor.dart';
|
|||
|
||||
void main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(RemoveUnnecessaryCastBulkTest);
|
||||
defineReflectiveTests(RemoveUnnecessaryCastMultiTest);
|
||||
defineReflectiveTests(RemoveUnnecessaryCastTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class RemoveUnnecessaryCastBulkTest extends BulkFixProcessorTest {
|
||||
Future<void> test_assignment() async {
|
||||
await resolveTestCode('''
|
||||
void f(Object p) {
|
||||
if (p is String) {
|
||||
var v = (p as String) as String;
|
||||
print(v);
|
||||
}
|
||||
}
|
||||
''');
|
||||
await assertHasFix('''
|
||||
void f(Object p) {
|
||||
if (p is String) {
|
||||
var v = p;
|
||||
print(v);
|
||||
}
|
||||
}
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class RemoveUnnecessaryCastMultiTest extends FixProcessorTest {
|
||||
@override
|
||||
|
@ -25,7 +48,7 @@ class RemoveUnnecessaryCastMultiTest extends FixProcessorTest {
|
|||
await resolveTestCode('''
|
||||
void f(Object p, Object q) {
|
||||
if (p is String) {
|
||||
String v = ((p as String));
|
||||
var v = (p as String) as String;
|
||||
print(v);
|
||||
}
|
||||
if (q is int) {
|
||||
|
@ -37,7 +60,7 @@ void f(Object p, Object q) {
|
|||
await assertHasFixAllFix(HintCode.UNNECESSARY_CAST, '''
|
||||
void f(Object p, Object q) {
|
||||
if (p is String) {
|
||||
String v = p;
|
||||
var v = p;
|
||||
print(v);
|
||||
}
|
||||
if (q is int) {
|
||||
|
|
Loading…
Reference in a new issue