Skip to content

Commit

Permalink
Version 3.5.0-206.0.dev
Browse files Browse the repository at this point in the history
Merge 13fb73d into dev
  • Loading branch information
Dart CI committed May 30, 2024
2 parents 8b00968 + 13fb73d commit aefbad6
Show file tree
Hide file tree
Showing 30 changed files with 651 additions and 66 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ vars = {
"flute_rev": "a531c96a8b43d015c6bfbbfe3ab54867b0763b8b",
"glob_rev": "ee48ea82a1ccb64c8cc62e9f4f44c44ca67add71",
"html_rev": "00d34611eee5eff976bd12a631357a4d591ef5fb",
"http_rev": "7df2ac8488ec69ee5945ae188625c0e820c4f63c",
"http_rev": "6337ee3f6d1f641192ba40e133f27085c69aa815",
"http_multi_server_rev": "4a791af861da1cf53b57d9928fbc605f57139e4f",
"http_parser_rev": "702698a3fc726f7cbb8cd7824a8639c7fe84b169",
"intl_rev": "5d65e3808ce40e6282e40881492607df4e35669f",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ class CreateLocalVariable extends ResolvedCorrectionProducer {
return;
}
}

// In `foo.bar`, `bar` is not a local variable.
// It also does not seem useful to suggest `foo`.
// So, always skip with these parents.
var parent = nameNode.parent;
switch (parent) {
case PrefixedIdentifier():
case PropertyAccess():
return;
}

// prepare target Statement
var target = node.thisOrAncestorOfType<Statement>();
if (target == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ class CreateMixin extends ResolvedCorrectionProducer {
_mixinName = node.name2.lexeme;
} else if (node is SimpleIdentifier) {
var parent = node.parent;
var grandParent = parent?.parent;
if (parent is NamedType &&
grandParent is ConstructorName &&
grandParent.parent is InstanceCreationExpression) {
return;
} else {
_mixinName = node.name;
switch (parent) {
case PrefixedIdentifier():
if (parent.identifier == node) {
return;
}
case PropertyAccess():
if (parent.propertyName == node) {
return;
}
}
_mixinName = node.name;
} else if (node is PrefixedIdentifier) {
if (node.parent is InstanceCreationExpression) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ abstract class _RemoveConst extends ParsedCorrectionProducer {
return;
} else if (expression is ClassDeclaration) {
constToken = expression.firstTokenAfterCommentAndMetadata.previous;
} else if (expression is ConstructorDeclaration) {
constToken = expression.constKeyword;
}

// Might be an implicit `const`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
#
# Stats:
# - 42 "needsEvaluation"
# - 356 "needsFix"
# - 395 "hasFix"
# - 354 "needsFix"
# - 397 "hasFix"
# - 516 "noFix"

AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR:
Expand Down Expand Up @@ -2588,9 +2588,7 @@ ParserErrorCode.CONST_CLASS:
ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY:
status: noFix
ParserErrorCode.CONST_FACTORY:
status: needsFix
notes: |-
Remove the `const` keyword.
status: hasFix
ParserErrorCode.CONST_METHOD:
status: needsFix
notes: |-
Expand Down Expand Up @@ -2863,9 +2861,7 @@ ParserErrorCode.FINAL_AND_VAR:
notes: |-
Remove either `final` or `var`.
ParserErrorCode.FINAL_CONSTRUCTOR:
status: needsFix
notes: |-
Remove the `final` keyword.
status: hasFix
ParserErrorCode.FINAL_ENUM:
status: needsFix
notes: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,9 @@ final _builtInNonLintProducers = <ErrorCode, List<ProducerGenerator>>{
ParserErrorCode.CONST_CLASS: [
RemoveConst.new,
],
ParserErrorCode.CONST_FACTORY: [
RemoveConst.new,
],
ParserErrorCode.DEFAULT_IN_SWITCH_EXPRESSION: [
ReplaceWithWildcard.new,
],
Expand All @@ -1372,6 +1375,9 @@ final _builtInNonLintProducers = <ErrorCode, List<ProducerGenerator>>{
ParserErrorCode.EXTRANEOUS_MODIFIER: [
RemoveExtraModifier.new,
],
ParserErrorCode.FINAL_CONSTRUCTOR: [
RemoveExtraModifier.new,
],
ParserErrorCode.GETTER_WITH_PARAMETERS: [
RemoveParametersInGetterDeclaration.new,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,33 @@ void f() {
''');
}

@failingTest
Future<void> test_propertyAccess() async {
// We should not offer to define a local variable named 'g'.
Future<void> test_read_prefixedIdentifier_identifier() async {
await resolveTestCode('''
void f(String s) {
s.g;
void f(C c) {
c.test;
}
class C {}
''');
await assertNoFix();
}

Future<void> test_read_prefixedIdentifier_prefix() async {
await resolveTestCode('''
void f() {
test.foo;
}
''');
await assertNoFix();
}

Future<void> test_read_propertyAccess_propertyName() async {
await resolveTestCode('''
void f(C c) {
(c).test;
}
class C {}
''');
await assertNoFix();
}
Expand Down Expand Up @@ -287,4 +307,35 @@ void f() {
}
''');
}

Future<void> test_write_prefixedIdentifier_identifier() async {
await resolveTestCode('''
void f(C c) {
c.test = 0;
}
class C {}
''');
await assertNoFix();
}

Future<void> test_write_prefixedIdentifier_prefix() async {
await resolveTestCode('''
void f() {
test.foo = 0;
}
''');
await assertNoFix();
}

Future<void> test_write_propertyAccess_propertyName() async {
await resolveTestCode('''
void f(C c) {
(c).test = 0;
}
class C {}
''');
await assertNoFix();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,45 @@ mixin Test {
assertLinkedGroup(change.linkedEditGroups[0], ['Test])', 'Test {']);
}

Future<void> test_prefixedIdentifier_identifier() async {
await resolveTestCode('''
void f(C c) {
c.test;
}
class C {}
''');
await assertNoFix();
}

Future<void> test_prefixedIdentifier_prefix() async {
await resolveTestCode('''
void f() {
Test.value;
}
''');
await assertHasFix('''
void f() {
Test.value;
}
mixin Test {
}
''');
assertLinkedGroup(change.linkedEditGroups[0], ['Test.value', 'Test {']);
}

Future<void> test_propertyAccess_property() async {
await resolveTestCode('''
void f(C c) {
(c).test;
}
class C {}
''');
await assertNoFix();
}

Future<void> test_simple() async {
await resolveTestCode('''
void f() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ class C {}
''');
}

Future<void> test_constFactoryConstructor() async {
await resolveTestCode('''
class C {
C._();
const factory C() => C._();
}
''');
await assertHasFix('''
class C {
C._();
factory C() => C._();
}
''');
}

@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/49818')
Future<void> test_constInitializedWithNonConstantValue() async {
await resolveTestCode('''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,19 @@ f() {
''');
}

Future<void> test_final_constructor() async {
await resolveTestCode('''
class C {
final C();
}
''');
await assertHasFix('''
class C {
C();
}
''');
}

Future<void> test_invalidAsyncConstructorModifier() async {
await resolveTestCode(r'''
class A {
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/dart/analysis/driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ import 'package:meta/meta.dart';
// TODO(scheglov): Clean up the list of implicitly analyzed files.
class AnalysisDriver {
/// The version of data format, should be incremented on every format change.
static const int DATA_VERSION = 365;
static const int DATA_VERSION = 366;

/// The number of exception contexts allowed to write. Once this field is
/// zero, we stop writing any new exception contexts in this process.
Expand Down
10 changes: 5 additions & 5 deletions pkg/analyzer/lib/src/summary2/bundle_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ class ClassElementLinkedData extends ElementLinkedData<ClassElementImpl> {
element.metadata = reader._readAnnotationList(
unitElement: unitElement,
);
element.macroDiagnostics = reader.readMacroDiagnostics();
_readTypeParameters(reader, element.typeParameters);
element.macroDiagnostics = reader.readMacroDiagnostics();
element.supertype = reader._readOptionalInterfaceType();
element.mixins = reader._readInterfaceTypeList();
element.interfaces = reader._readInterfaceTypeList();
Expand Down Expand Up @@ -513,8 +513,8 @@ class FunctionElementLinkedData extends ElementLinkedData<FunctionElementImpl> {
element.metadata = reader._readAnnotationList(
unitElement: unitElement,
);
element.macroDiagnostics = reader.readMacroDiagnostics();
_readTypeParameters(reader, element.typeParameters);
element.macroDiagnostics = reader.readMacroDiagnostics();
element.returnType = reader.readRequiredType();
_readFormalParameters(reader, element.parameters);
element.augmentation = reader.readElement() as FunctionElementImpl?;
Expand Down Expand Up @@ -1872,8 +1872,8 @@ class MethodElementLinkedData extends ElementLinkedData<MethodElementImpl> {
element.metadata = reader._readAnnotationList(
unitElement: unitElement,
);
element.macroDiagnostics = reader.readMacroDiagnostics();
_readTypeParameters(reader, element.typeParameters);
element.macroDiagnostics = reader.readMacroDiagnostics();
_readFormalParameters(reader, element.parameters);
element.returnType = reader.readRequiredType();
element.augmentation = reader.readElement() as MethodElementImpl?;
Expand Down Expand Up @@ -1902,8 +1902,8 @@ class MixinElementLinkedData extends ElementLinkedData<MixinElementImpl> {
element.metadata = reader._readAnnotationList(
unitElement: element.enclosingElement,
);
element.macroDiagnostics = reader.readMacroDiagnostics();
_readTypeParameters(reader, element.typeParameters);
element.macroDiagnostics = reader.readMacroDiagnostics();
element.superclassConstraints = reader._readInterfaceTypeList();
element.interfaces = reader._readInterfaceTypeList();
element.augmentationTargetAny = reader.readElement() as ElementImpl?;
Expand Down Expand Up @@ -2669,8 +2669,8 @@ class TypeAliasElementLinkedData
element.metadata = reader._readAnnotationList(
unitElement: unitElement,
);
element.macroDiagnostics = reader.readMacroDiagnostics();
_readTypeParameters(reader, element.typeParameters);
element.macroDiagnostics = reader.readMacroDiagnostics();
element.aliasedElement = reader._readAliasedElement(unitElement);
element.aliasedType = reader.readRequiredType();
applyConstantOffsets?.perform();
Expand Down
Loading

0 comments on commit aefbad6

Please sign in to comment.