Skip to content

Commit

Permalink
Version 3.5.0-191.0.dev
Browse files Browse the repository at this point in the history
Merge 1e93516 into dev
  • Loading branch information
Dart CI committed May 24, 2024
2 parents 4ef8ed6 + 1e93516 commit 641d613
Show file tree
Hide file tree
Showing 81 changed files with 120 additions and 15,599 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ class RemoveTypeArguments extends ResolvedCorrectionProducer {

@override
Future<void> compute(ChangeBuilder builder) async {
var typeArguments = coveringNode;
if (typeArguments is! TypeArgumentList) {
return;
var node = coveringNode;
// A<int>.i;
if (node is ConstructorName) {
node = node.type.typeArguments;
}
if (node is! TypeArgumentList) return;

await builder.addDartFileEdit(file, (builder) {
builder.addDeletion(range.node(typeArguments));
builder.addDeletion(range.node(node!));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
#
# Stats:
# - 42 "needsEvaluation"
# - 363 "needsFix"
# - 388 "hasFix"
# - 361 "needsFix"
# - 390 "hasFix"
# - 516 "noFix"

AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR:
Expand Down Expand Up @@ -118,9 +118,7 @@ AnalysisOptionsWarningCode.REPLACED_LINT:
notes: |-
We should be able to replace the deprecated lint rule with its replacement.
AnalysisOptionsWarningCode.UNDEFINED_LINT:
status: needsFix
notes: |-
The fix is to remove the name of the lint rule.
status: hasFix
AnalysisOptionsWarningCode.UNRECOGNIZED_ERROR_CODE:
status: needsFix
notes: |-
Expand Down Expand Up @@ -293,10 +291,7 @@ CompileTimeErrorCode.CLASS_INSTANTIATION_ACCESS_TO_INSTANCE_MEMBER:
status: noFix
since: 2.15
CompileTimeErrorCode.CLASS_INSTANTIATION_ACCESS_TO_STATIC_MEMBER:
status: needsFix
notes: |-
The fix is to remove the type arguments.
since: 2.15
status: hasFix
CompileTimeErrorCode.CLASS_INSTANTIATION_ACCESS_TO_UNKNOWN_MEMBER:
status: noFix
notes: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class AnalysisOptionsFixGenerator {
AnalysisOptionsWarningCode.ANALYSIS_OPTION_DEPRECATED_WITH_REPLACEMENT,
AnalysisOptionsHintCode.DUPLICATE_RULE,
AnalysisOptionsWarningCode.REMOVED_LINT,
AnalysisOptionsWarningCode.UNDEFINED_LINT,
AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITHOUT_VALUES,
];

Expand Down Expand Up @@ -101,7 +102,8 @@ class AnalysisOptionsFixGenerator {
}
} else if (errorCode == AnalysisOptionsHintCode.DEPRECATED_LINT ||
errorCode == AnalysisOptionsHintCode.DUPLICATE_RULE ||
errorCode == AnalysisOptionsWarningCode.REMOVED_LINT) {
errorCode == AnalysisOptionsWarningCode.REMOVED_LINT ||
errorCode == AnalysisOptionsWarningCode.UNDEFINED_LINT) {
await _addFix_removeLint(coveringNodePath);
} else if (errorCode ==
AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITHOUT_VALUES) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,9 @@ final _builtInNonLintProducers = <ErrorCode, List<ProducerGenerator>>{
CreateClass.new,
CreateMixin.new,
],
CompileTimeErrorCode.CLASS_INSTANTIATION_ACCESS_TO_STATIC_MEMBER: [
RemoveTypeArguments.new,
],
CompileTimeErrorCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER: [
ConvertIntoBlockBody.missingBody,
CreateNoSuchMethod.new,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ linter:
- camel_case_types
- removed_rule
''', '''
linter:
rules:
- camel_case_types
''');
}

Future<void> test_undefined() async {
await assertHasFix('''
linter:
rules:
- camel_case_types
- undefined_rule
''', '''
linter:
rules:
- camel_case_types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ class RemoveTypeArgumentsTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.REMOVE_TYPE_ARGUMENTS;

Future<void> test_classInstantiationAccessToStaticMember() async {
await resolveTestCode('''
class A<T> {
static int i = 1;
}
var x = A<int>.i;
''');
await assertHasFix('''
class A<T> {
static int i = 1;
}
var x = A.i;
''');
}

Future<void> test_explicitConst() async {
await resolveTestCode('''
void f() {
Expand Down
108 changes: 26 additions & 82 deletions pkg/analyzer/test/src/diagnostics/assignment_of_do_not_store_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,24 +129,6 @@ class B {
]);
}

@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_classMemberVariable() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
class A{
@doNotStore
final f = '';
}
class B {
String f = A().f;
}
''', [
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 99, 5),
]);
}

test_classStaticGetter() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
Expand All @@ -164,24 +146,6 @@ class B {
]);
}

@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_classStaticVariable() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
class A{
@doNotStore
static final f = '';
}
class B {
String f = A.f;
}
''', [
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 106, 3),
]);
}

test_functionAssignment() async {
await assertNoErrorsInCode('''
import 'package:meta/meta.dart';
Expand Down Expand Up @@ -272,23 +236,36 @@ class A {
]);
}

@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_topLevelVariable() async {
test_topLevelGetter_binaryExpression() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
@doNotStore
final v = '';
String? get v => '';
class A {
final f = v;
final f = v ?? v;
}
''', [
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 83, 1),
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 90, 1),
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 95, 1),
]);
}

test_topLevelGVariable_assignment_getter() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
String top = v;
@doNotStore
String get v => '';
''', [
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 47, 1,
messageContains: ["'v'"]),
]);
}

@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_topLevelVariable_assignment_field() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
Expand All @@ -297,41 +274,26 @@ String top = A().f;
class A{
@doNotStore
final f = '';
String get f => '';
}
''', [
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 47, 5,
messageContains: ["'f'"]),
]);
}

@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_topLevelVariable_assignment_functionExpression() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
@doNotStore
String _v = '';
String get _v => '';
var c = ()=> _v;
var c = () => _v;
String v = c();
''', [
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 76, 2),
]);
}

test_topLevelVariable_assignment_getter() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
String top = v;
@doNotStore
String get v => '';
''', [
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 47, 1,
messageContains: ["'v'"]),
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 82, 2),
]);
}

Expand All @@ -351,23 +313,6 @@ class A{
]);
}

@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_topLevelVariable_binaryExpression() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
@doNotStore
final String? v = '';
class A {
final f = v ?? v;
}
''', [
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 91, 1),
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 96, 1),
]);
}

test_topLevelVariable_libraryAnnotation() async {
newFile('$testPackageLibPath/library.dart', '''
@doNotStore
Expand All @@ -389,21 +334,20 @@ class A {
]);
}

@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_topLevelVariable_ternary() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
@doNotStore
final v = '';
String get v => '';
class A {
static bool c = false;
final f = c ? v : v;
}
''', [
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 112, 1),
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 116, 1),
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 118, 1),
error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 122, 1),
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ void f(void Function() m) {
''');
}

@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_functionType_optionalTypeArgs() async {
await assertNoErrorsInCode('''
import 'package:meta/meta.dart';
void f(@optionalTypeArgs void Function<T>() m) {
m();
}
''');
}

test_genericFunctionExpression_explicitTypeArg() async {
await assertNoErrorsInCode('''
void f(void Function<T>()? m, void Function<T>() n) {
Expand Down
Loading

0 comments on commit 641d613

Please sign in to comment.