Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump analyzer to 6.5.0 #3763

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
sdk: [dev, stable]
# TODO(srawlins): Re-enable stable after 3.4.0 ships.
# sdk: [dev, stable]
sdk: [dev]
job: [main, flutter, packages, sdk-docs]
include:
- os: macos-latest
Expand Down
23 changes: 14 additions & 9 deletions lib/src/generator/templates.runtime_renderers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2668,7 +2668,7 @@ class _Renderer_Container extends RendererBase<Container> {
renderVariable: (CT_ c, Property<CT_> self,
List<String> remainingNames) =>
self.renderSimpleVariable(
c, remainingNames, 'Set<Element>'),
c, remainingNames, 'Set<Element?>'),
renderIterable: (CT_ c, RendererBase<CT_> r,
List<MustachioNode> ast, StringSink sink) {
return c.allElements.map((e) => renderSimple(
Expand Down Expand Up @@ -10203,7 +10203,7 @@ class _Renderer_ModelElement extends RendererBase<ModelElement> {
renderVariable: (CT_ c, Property<CT_> self,
List<String> remainingNames) =>
self.renderSimpleVariable(
c, remainingNames, 'Iterable<Category>'),
c, remainingNames, 'Iterable<Category?>'),
renderIterable: (CT_ c, RendererBase<CT_> r,
List<MustachioNode> ast, StringSink sink) {
return c.displayedCategories.map((e) =>
Expand Down Expand Up @@ -12036,7 +12036,7 @@ class _Renderer_Package extends RendererBase<Package> {
renderVariable: (CT_ c, Property<CT_> self,
List<String> remainingNames) =>
self.renderSimpleVariable(
c, remainingNames, 'Map<String, Category>'),
c, remainingNames, 'Map<String?, Category>'),
isNullValue: (CT_ c) => false,
renderValue: (CT_ c, RendererBase<CT_> r,
List<MustachioNode> ast, StringSink sink) {
Expand Down Expand Up @@ -12202,7 +12202,7 @@ class _Renderer_Package extends RendererBase<Package> {
renderVariable: (CT_ c, Property<CT_> self,
List<String> remainingNames) =>
self.renderSimpleVariable(
c, remainingNames, 'Map<String, Set<String>>'),
c, remainingNames, 'Map<String?, Set<String>>'),
isNullValue: (CT_ c) => false,
renderValue: (CT_ c, RendererBase<CT_> r,
List<MustachioNode> ast, StringSink sink) {
Expand Down Expand Up @@ -15762,7 +15762,6 @@ const _invisibleGetters = {
'isDartCoreObject',
'isExhaustive',
'isFinal',
'isInline',
'isInterface',
'isMixinApplication',
'isMixinClass',
Expand Down Expand Up @@ -15926,13 +15925,15 @@ const _invisibleGetters = {
'hasAlwaysThrows',
'hasDeprecated',
'hasDoNotStore',
'hasDoNotSubmit',
'hasFactory',
'hasImmutable',
'hasInternal',
'hasIsTest',
'hasIsTestGroup',
'hasJS',
'hasLiteral',
'hasMustBeConst',
'hasMustBeOverridden',
'hasMustCallSuper',
'hasNonVirtual',
Expand Down Expand Up @@ -15984,6 +15985,7 @@ const _invisibleGetters = {
'hasAlwaysThrows',
'hasDeprecated',
'hasDoNotStore',
'hasDoNotSubmit',
'hasFactory',
'hasImmutable',
'hasImplicitReturnType',
Expand All @@ -15992,6 +15994,7 @@ const _invisibleGetters = {
'hasIsTestGroup',
'hasJS',
'hasLiteral',
'hasMustBeConst',
'hasMustBeOverridden',
'hasMustCallSuper',
'hasNonVirtual',
Expand All @@ -16015,7 +16018,6 @@ const _invisibleGetters = {
'isExtensionTypeMember',
'isExternal',
'isGenerator',
'isLegacy',
'isOperator',
'isPrivate',
'isPublic',
Expand Down Expand Up @@ -16247,13 +16249,15 @@ const _invisibleGetters = {
'hasAlwaysThrows',
'hasDeprecated',
'hasDoNotStore',
'hasDoNotSubmit',
'hasFactory',
'hasImmutable',
'hasInternal',
'hasIsTest',
'hasIsTestGroup',
'hasJS',
'hasLiteral',
'hasMustBeConst',
'hasMustBeOverridden',
'hasMustCallSuper',
'hasNonVirtual',
Expand All @@ -16271,7 +16275,6 @@ const _invisibleGetters = {
'hasVisibleOutsideTemplate',
'hashCode',
'id',
'isLegacy',
'isPrivate',
'isPublic',
'isSynthetic',
Expand Down Expand Up @@ -16399,6 +16402,7 @@ const _invisibleGetters = {
'hasDefaultValue',
'hasDeprecated',
'hasDoNotStore',
'hasDoNotSubmit',
'hasFactory',
'hasImmutable',
'hasImplicitType',
Expand All @@ -16407,6 +16411,7 @@ const _invisibleGetters = {
'hasIsTestGroup',
'hasJS',
'hasLiteral',
'hasMustBeConst',
'hasMustBeOverridden',
'hasMustCallSuper',
'hasNonVirtual',
Expand All @@ -16430,7 +16435,6 @@ const _invisibleGetters = {
'isFinal',
'isInitializingFormal',
'isLate',
'isLegacy',
'isPrivate',
'isPublic',
'isStatic',
Expand Down Expand Up @@ -16467,7 +16471,8 @@ const _invisibleGetters = {
'isGetter',
'isSetter',
'runtimeType',
'variable'
'variable',
'variable2'
},
'Scope': {'hashCode', 'runtimeType'},
'TemplateOptions': {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/model/accessor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class Accessor extends ModelElement {

bool get isSynthetic => element.isSynthetic;

// The [enclosingCombo] where this element was defined.
/// The [enclosingCombo] where this element was defined.
late final GetterSetterCombo definingCombo =
getModelForElement(element.variable) as GetterSetterCombo;
getModelForElement(element.variable2!) as GetterSetterCombo;

String get _sourceCode {
if (!isSynthetic) {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/model/annotation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ final class Annotation extends Attribute {
late final ElementType _modelType = switch (_annotation.element) {
ConstructorElement(:var returnType) =>
_packageGraph.getTypeFor(returnType, _library),
PropertyAccessorElement(:var variable) =>
(_packageGraph.getModelForElement(variable) as GetterSetterCombo)
PropertyAccessorElement(:var variable2?) =>
(_packageGraph.getModelForElement(variable2) as GetterSetterCombo)
.modelType,
_ => throw StateError(
'non-callable element used as annotation?: ${_annotation.element}')
Expand Down
2 changes: 1 addition & 1 deletion lib/src/model/comment_referable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ mixin CommentReferable implements Nameable {
if (resultElement == null) return null;
ModelElement result;
if (resultElement is PropertyAccessorElement) {
final variable = resultElement.variable;
final variable = resultElement.variable2!;
if (variable.isSynthetic) {
result = packageGraph.getModelForElement(resultElement);
} else {
Expand Down
42 changes: 12 additions & 30 deletions lib/src/model/inheriting_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ import 'package:meta/meta.dart';
/// Note that [Constructor]s are not considered to be modifiers so a
/// [hasModifiers] override is not necessary for this mixin.
mixin Constructable implements InheritingContainer {
late final List<Constructor> constructors =
// TODO(srawlins): Remove this and deal with the follow-on effects, when
// `.augmented` becomes non-nullable.
// ignore: invalid_null_aware_operator
(element.augmented?.constructors ?? element.constructors)
.map((e) => getModelFor(e, library) as Constructor)
.toList(growable: false);
late final List<Constructor> constructors = element.augmented.constructors
.map((e) => getModelFor(e, library) as Constructor)
.toList(growable: false);

@override
late final List<Constructor> publicConstructorsSorted =
Expand Down Expand Up @@ -157,11 +153,11 @@ abstract class InheritingContainer extends Container {
// The mapping of all of the inherited element names to their _concrete_
// implementation element.
var concreteInheritanceMap = packageGraph.inheritanceManager
.getInheritedConcreteMap2(element.augmentedDeclarationOrSelf);
.getInheritedConcreteMap2(element.augmented.declaration);
// The mapping of all inherited element names to the nearest inherited
// element that they resolve to.
var inheritanceMap = packageGraph.inheritanceManager
.getInheritedMap2(element.augmentedDeclarationOrSelf);
.getInheritedMap2(element.augmented.declaration);

var inheritanceChainElements =
inheritanceChain.map((c) => c.element).toList(growable: false);
Expand Down Expand Up @@ -259,13 +255,9 @@ abstract class InheritingContainer extends Container {
}();

@override
late final List<Method> declaredMethods =
// TODO(srawlins): Remove this and deal with the follow-on effects, when
// `.augmented` becomes non-nullable.
// ignore: invalid_null_aware_operator
(element.augmented?.methods ?? element.methods)
.map((e) => getModelFor(e, library) as Method)
.toList(growable: false);
late final List<Method> declaredMethods = element.augmented.methods
.map((e) => getModelFor(e, library) as Method)
.toList(growable: false);

@override
late final List<TypeParameter> typeParameters = element.typeParameters
Expand Down Expand Up @@ -538,9 +530,9 @@ abstract class InheritingContainer extends Container {
// Pick an appropriate [FieldElement] to represent this element.
// Only hard when dealing with a synthetic [Field].
if (getter != null && setter == null) {
field = getterElement!.variable as FieldElement;
field = getterElement!.variable2 as FieldElement;
} else if (getter == null && setter != null) {
field = setterElement!.variable as FieldElement;
field = setterElement!.variable2 as FieldElement;
} else {
// In this case: `getter != null && setter != null`.
getter!;
Expand All @@ -553,9 +545,9 @@ abstract class InheritingContainer extends Container {
if (setterEnclosingElement is Class &&
setterEnclosingElement._isInheritingFrom(
getter.enclosingElement as InheritingContainer)) {
field = setterElement!.variable as FieldElement;
field = setterElement!.variable2 as FieldElement;
} else {
field = getterElement!.variable as FieldElement;
field = getterElement!.variable2 as FieldElement;
}
}
}
Expand Down Expand Up @@ -601,16 +593,6 @@ mixin MixedInTypes on InheritingContainer {
mixedInTypes.wherePublic;
}

extension on InterfaceElement {
/// This element's augmented declaration, or, if there is none, then just this
/// element itself.
InterfaceElement get augmentedDeclarationOrSelf =>
// TODO(srawlins): Remove this and deal with the follow-on effects, when
// `.augmented` becomes non-nullable.
// ignore: invalid_null_aware_operator
augmented?.declaration ?? this;
}

extension on InterfaceElement {
bool get isDartCoreObject => name == 'Object' && library.name == 'dart.core';
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/model/library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ class Library extends ModelElement
..._exportedAndLocalElements.whereType<TopLevelVariableElement>(),
..._exportedAndLocalElements
.whereType<PropertyAccessorElement>()
.map((a) => a.variable as TopLevelVariableElement)
.map((a) => a.variable2! as TopLevelVariableElement)
};
var variables = <TopLevelVariable>[];
for (var element in elements) {
Expand Down
6 changes: 1 addition & 5 deletions lib/src/model/method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,7 @@ class Method extends ModelElement
return null;
}
var parent = element.enclosingElement as InterfaceElement;
// TODO(srawlins): Remove this and deal with the follow-on effects, when
// `.augmented` becomes non-nullable.
// ignore: invalid_null_aware_operator
var parentDeclaration = parent.augmented?.declaration ?? parent;
for (var t in parentDeclaration.allSupertypes) {
for (var t in parent.augmented.declaration.allSupertypes) {
Element? e = t.getMethod(element.name);
if (e != null) {
assert(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/model/model_element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ abstract class ModelElement
var lookup =
l.element.exportNamespace.definedNames[topLevelElement.name!];
return switch (lookup) {
PropertyAccessorElement() => topLevelElement == lookup.variable,
PropertyAccessorElement() => topLevelElement == lookup.variable2,
_ => topLevelElement == lookup,
};
}).toList(growable: true);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/model/package_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ class PackageGraph with CommentReferable, Nameable {
_canonicalLibraryFor[e] = null;

var searchElement = switch (e) {
PropertyAccessorElement() => e.variable,
PropertyAccessorElement() => e.variable2,
GenericFunctionTypeElement() => e.enclosingElement,
_ => e,
};
Expand Down
12 changes: 6 additions & 6 deletions lib/src/mustachio/renderer_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ abstract class RendererBase<T extends Object?> {
String get contextChainString =>
parent == null ? '$T' : '${parent!.contextChainString} > $T';

/// Returns the [Property] on this renderer named [name].
/// Returns the [Property] on this renderer named [key].
///
/// If no property named [name] exists for this renderer, `null` is returned.
/// If no property named [key] exists for this renderer, `null` is returned.
Property<T>? getProperty(String key);

/// Resolves [names] into one or more field accesses, returning the result as
/// Resolves [node] into one or more field accesses, returning the result as
/// a String.
///
/// [names] may have multiple dot-separate names, and [names] may not be a
/// [node]'s `key` may have multiple dot-separate names, and it may not be a
/// valid property of _this_ context type, in which the [parent] renderer is
/// referenced.
String getFields(Variable node) {
Expand Down Expand Up @@ -347,13 +347,13 @@ class SimpleRenderer extends RendererBase<Object?> {
/// rendering various types of Mustache nodes.
@immutable
class Property<T extends Object?> {
/// Gets the value of this property on the object [context].
/// Gets the value of this property on the object `context`.
final Object? Function(T context) getValue;

final String Function(T, Property<T>, List<String>) renderVariable;

/// Gets the bool value (true or false, never null) of this property on the
/// object [context].
/// object `context`.
final bool Function(T context)? getBool;

final Iterable<void> Function(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ environment:
sdk: ^3.2.0

dependencies:
analyzer: ^6.4.1
analyzer: ^6.5.0
args: ^2.4.1
collection: ^1.17.0
crypto: ^3.0.3
Expand Down
2 changes: 1 addition & 1 deletion test/mustachio/aot_compiler_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Baz {}
var fooRenderFunction = renderersLibrary.getTopLevelFunction('renderFoo')!;
expect(fooRenderFunction.typeParameters, hasLength(1));
var fBound = fooRenderFunction.typeParameters.single.bound!;
expect(fBound.getDisplayString(withNullability: false), equals('num'));
expect(fBound.getDisplayString(), equals('num'));
});

test('deduplicates partials which share context type LUB', () async {
Expand Down
4 changes: 2 additions & 2 deletions test/mustachio/runtime_renderer_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ class Baz {}
var fooRenderFunction = renderersLibrary.getTopLevelFunction('renderFoo')!;
expect(fooRenderFunction.typeParameters, hasLength(1));
var fBound = fooRenderFunction.typeParameters.single.bound!;
expect(fBound.getDisplayString(withNullability: false), equals('num'));
expect(fBound.getDisplayString(), equals('num'));

var fooRendererClass = renderersLibrary.getClass('_Renderer_Foo')!;
expect(fooRendererClass.typeParameters, hasLength(1));
var cBound = fooRenderFunction.typeParameters.single.bound!;
expect(cBound.getDisplayString(withNullability: false), equals('num'));
expect(cBound.getDisplayString(), equals('num'));
});

group('does not generate a renderer', () {
Expand Down
Loading
Loading