Skip to content

Commit

Permalink
Version 3.6.0-254.0.dev
Browse files Browse the repository at this point in the history
Merge 4819bd0 into dev
  • Loading branch information
Dart CI committed Sep 13, 2024
2 parents 302b647 + 4819bd0 commit c0f7e39
Show file tree
Hide file tree
Showing 31 changed files with 245 additions and 125 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ vars = {

# co19 is a cipd package automatically generated for each co19 commit.
# Use tests/co19/update.sh to update this hash.
"co19_rev": "a572236bc7d760dc986fd34abe6d0b8ae56254d7",
"co19_rev": "baa1dd9ca815d468720d9f456e7f7498845222dc",

# The internal benchmarks to use. See go/dart-benchmarks-internal
"benchmarks_internal_rev": "3bd6bc6d207dfb7cf687537e819863cf9a8f2470",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class _LintRuleProducer extends Producer {
for (var rule in Registry.ruleRegistry.rules) {
// TODO(pq): consider suggesting internal lints if editing an SDK options file
if (!rule.state.isInternal) {
yield identifier(rule.name, docComplete: rule.details);
yield identifier(rule.name, docComplete: rule.description);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ linter:
var completion = assertSuggestion('annotate_overrides');
expect(
completion.docComplete,
contains('**DO** annotate overridden methods and fields'),
contains('Annotate overridden members.'),
);
}

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 @@ -96,7 +96,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 = 385;
static const int DATA_VERSION = 386;

/// 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
6 changes: 5 additions & 1 deletion pkg/analyzer/lib/src/lint/linter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ abstract class LintRule {

/// Description (in markdown format) suitable for display in a detailed lint
/// description.
///
/// This property is deprecated and will be removed in a future release.
@Deprecated('Use .description for a short description and consider placing '
'long-form documentation on an external website.')
final String details;

/// Short description suitable for display in console output.
Expand All @@ -213,7 +217,7 @@ abstract class LintRule {
required this.name,
this.categories = const <String>{},
required this.description,
required this.details,
this.details = '',
State? state,
}) : state = state ?? State.stable();

Expand Down
16 changes: 8 additions & 8 deletions pkg/analyzer/lib/src/summary2/bundle_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1531,8 +1531,6 @@ class LibraryReader {
List<PropertyInducingElement> properties,
String containerRefName,
) {
var containerRef = enclosingReference.getChild(containerRefName);

var accessorCount = _reader.readUInt30();
for (var i = 0; i < accessorCount; i++) {
var accessor = _readPropertyAccessorElement(
Expand All @@ -1546,6 +1544,9 @@ class LibraryReader {
continue;
}

// Read the property reference.
var propertyReference = _readReference();

var name = accessor.displayName;
var isGetter = accessor.isGetter;

Expand All @@ -1555,8 +1556,7 @@ class LibraryReader {
}

PropertyInducingElementImpl property;
var reference = containerRef.getChild(name);
var existing = reference.element;
var existing = propertyReference.element;
if (enclosingElement is CompilationUnitElementImpl) {
if (existing is TopLevelVariableElementImpl &&
canUseExisting(existing)) {
Expand All @@ -1565,9 +1565,9 @@ class LibraryReader {
property = TopLevelVariableElementImpl(name, -1)
..enclosingElement = enclosingElement
..enclosingElement3 = enclosingElement
..reference = reference
..reference = propertyReference
..isSynthetic = true;
reference.element ??= property;
propertyReference.element ??= property;
properties.add(property);
}
} else {
Expand All @@ -1577,10 +1577,10 @@ class LibraryReader {
property = FieldElementImpl(name, -1)
..enclosingElement = enclosingElement
..enclosingElement3 = enclosingElement
..reference = reference
..reference = propertyReference
..isStatic = accessor.isStatic
..isSynthetic = true;
reference.element ??= property;
propertyReference.element ??= property;
properties.add(property);
}
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/analyzer/lib/src/summary2/bundle_writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,11 @@ class BundleWriter {
_resolutionSink.writeType(element.returnType);
_writeList(element.parameters, _writeParameterElement);

// Write the reference for the variable, the reader will use it.
if (!element.isAugmentation) {
_writeReference(element.variable2!);
}

_resolutionSink.writeElement(element.augmentationTargetAny);
if (element.isAugmentation) {
_accessorAugmentations.add(element);
Expand Down
41 changes: 30 additions & 11 deletions pkg/analyzer/lib/src/summary2/element_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1381,23 +1381,42 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
accessorElement.isSetter && property.setter == null;
}

PropertyInducingElementImpl property;
PropertyInducingElementImpl? property;
if (enclosingElement is CompilationUnitElement) {
var reference = enclosingRef.getChild('@topLevelVariable').getChild(name);
var existing = reference.element;
if (existing is TopLevelVariableElementImpl && canUseExisting(existing)) {
property = existing;
} else {
// Try to find the variable to attach the accessor.
var containerRef = enclosingRef.getChild('@topLevelVariable');
for (var reference in containerRef.getChildrenByName(name)) {
var existing = reference.element;
if (existing is TopLevelVariableElementImpl &&
canUseExisting(existing)) {
property = existing;
break;
}
}

// If no variable, add a new one.
// In error cases could be a duplicate.
if (property == null) {
var reference = containerRef.addChild(name);
var variable = property = TopLevelVariableElementImpl(name, -1)
..isSynthetic = true;
_enclosingContext.addTopLevelVariableSynthetic(reference, variable);
}
} else {
var reference = enclosingRef.getChild('@field').getChild(name);
var existing = reference.element;
if (existing is FieldElementImpl && canUseExisting(existing)) {
property = existing;
} else {
// Try to find the variable to attach the accessor.
var containerRef = enclosingRef.getChild('@field');
for (var reference in containerRef.getChildrenByName(name)) {
var existing = reference.element;
if (existing is FieldElementImpl && canUseExisting(existing)) {
property = existing;
break;
}
}

// If no variable, add a new one.
// In error cases could be a duplicate.
if (property == null) {
var reference = containerRef.addChild(name);
var field = property = FieldElementImpl(name, -1)
..isStatic = accessorElement.isStatic
..isSynthetic = true;
Expand Down
20 changes: 20 additions & 0 deletions pkg/analyzer/lib/src/summary2/reference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,26 @@ class Reference {
Reference._(this, name);
}

/// Returns children with the given name.
/// Usually returns zero or one child.
/// But in case of duplicates will return more than one.
List<Reference> getChildrenByName(String name) {
var result = this[name];

// No such child yet.
if (result == null) {
return const [];
}

// Maybe has the container with duplicates.
if (result[_defName] case var defContainer?) {
return defContainer.children.toList();
}

// Should be the only child with such name.
return [result];
}

Reference? removeChild(String name) {
var childrenUnion = _childrenUnion;
if (childrenUnion == null) return null;
Expand Down
48 changes: 34 additions & 14 deletions pkg/analyzer/test/src/summary/elements/class_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10813,7 +10813,9 @@ class C {
int get foo => 0;
}
''');
configuration.withPropertyLinking = true;
configuration
..withAugmentedWithoutAugmentation = true
..withPropertyLinking = true;
checkElementText(library, r'''
library
reference: <testLibrary>
Expand All @@ -10827,15 +10829,15 @@ library
enclosingElement3: <testLibraryFragment>
fields
foo @16
reference: <testLibraryFragment>::@class::C::@field::foo
reference: <testLibraryFragment>::@class::C::@field::foo::@def::0
enclosingElement3: <testLibraryFragment>::@class::C
type: int
shouldUseTypeForInitializerInference: true
id: field_0
getter: getter_0
setter: setter_0
synthetic foo @-1
reference: <testLibraryFragment>::@class::C::@field::foo
reference: <testLibraryFragment>::@class::C::@field::foo::@def::1
enclosingElement3: <testLibraryFragment>::@class::C
type: int
id: field_1
Expand Down Expand Up @@ -10866,6 +10868,14 @@ library
returnType: int
id: getter_1
variable: field_1
augmented
fields
<testLibraryFragment>::@class::C::@field::foo::@def::0
<testLibraryFragment>::@class::C::@field::foo::@def::1
accessors
<testLibraryFragment>::@class::C::@getter::foo::@def::0
<testLibraryFragment>::@class::C::@getter::foo::@def::1
<testLibraryFragment>::@class::C::@setter::foo
----------------------------------------
library
reference: <testLibrary>
Expand All @@ -10878,12 +10888,12 @@ library
element: <testLibraryFragment>::@class::C
fields
foo @16
reference: <testLibraryFragment>::@class::C::@field::foo
reference: <testLibraryFragment>::@class::C::@field::foo::@def::0
element: <none>
getter2: <testLibraryFragment>::@class::C::@getter::foo::@def::0
setter2: <testLibraryFragment>::@class::C::@setter::foo
foo @-1
reference: <testLibraryFragment>::@class::C::@field::foo
reference: <testLibraryFragment>::@class::C::@field::foo::@def::1
element: <none>
getter2: <testLibraryFragment>::@class::C::@getter::foo::@def::1
constructors
Expand Down Expand Up @@ -10912,13 +10922,13 @@ library
foo
reference: <none>
type: int
firstFragment: <testLibraryFragment>::@class::C::@field::foo
firstFragment: <testLibraryFragment>::@class::C::@field::foo::@def::0
getter: <none>
setter: <none>
synthetic foo
reference: <none>
type: int
firstFragment: <testLibraryFragment>::@class::C::@field::foo
firstFragment: <testLibraryFragment>::@class::C::@field::foo::@def::1
getter: <none>
constructors
synthetic new
Expand Down Expand Up @@ -10949,7 +10959,9 @@ class C {
set foo(int _) {}
}
''');
configuration.withPropertyLinking = true;
configuration
..withAugmentedWithoutAugmentation = true
..withPropertyLinking = true;
checkElementText(library, r'''
library
reference: <testLibrary>
Expand All @@ -10963,15 +10975,15 @@ library
enclosingElement3: <testLibraryFragment>
fields
foo @16
reference: <testLibraryFragment>::@class::C::@field::foo
reference: <testLibraryFragment>::@class::C::@field::foo::@def::0
enclosingElement3: <testLibraryFragment>::@class::C
type: int
shouldUseTypeForInitializerInference: true
id: field_0
getter: getter_0
setter: setter_0
synthetic foo @-1
reference: <testLibraryFragment>::@class::C::@field::foo
reference: <testLibraryFragment>::@class::C::@field::foo::@def::1
enclosingElement3: <testLibraryFragment>::@class::C
type: int
id: field_1
Expand Down Expand Up @@ -11005,6 +11017,14 @@ library
returnType: void
id: setter_1
variable: field_1
augmented
fields
<testLibraryFragment>::@class::C::@field::foo::@def::0
<testLibraryFragment>::@class::C::@field::foo::@def::1
accessors
<testLibraryFragment>::@class::C::@getter::foo
<testLibraryFragment>::@class::C::@setter::foo::@def::0
<testLibraryFragment>::@class::C::@setter::foo::@def::1
----------------------------------------
library
reference: <testLibrary>
Expand All @@ -11017,12 +11037,12 @@ library
element: <testLibraryFragment>::@class::C
fields
foo @16
reference: <testLibraryFragment>::@class::C::@field::foo
reference: <testLibraryFragment>::@class::C::@field::foo::@def::0
element: <none>
getter2: <testLibraryFragment>::@class::C::@getter::foo
setter2: <testLibraryFragment>::@class::C::@setter::foo::@def::0
foo @-1
reference: <testLibraryFragment>::@class::C::@field::foo
reference: <testLibraryFragment>::@class::C::@field::foo::@def::1
element: <none>
setter2: <testLibraryFragment>::@class::C::@setter::foo::@def::1
constructors
Expand Down Expand Up @@ -11054,13 +11074,13 @@ library
foo
reference: <none>
type: int
firstFragment: <testLibraryFragment>::@class::C::@field::foo
firstFragment: <testLibraryFragment>::@class::C::@field::foo::@def::0
getter: <none>
setter: <none>
synthetic foo
reference: <none>
type: int
firstFragment: <testLibraryFragment>::@class::C::@field::foo
firstFragment: <testLibraryFragment>::@class::C::@field::foo::@def::1
setter: <none>
constructors
synthetic new
Expand Down
Loading

0 comments on commit c0f7e39

Please sign in to comment.