Version 2.18.0-239.0.dev
Merge commit 'bd660d98472f01c57ece4dcf2a7a8810ea4e402d' into 'dev'
diff --git a/pkg/_fe_analyzer_shared/analysis_options.yaml b/pkg/_fe_analyzer_shared/analysis_options.yaml
index 9021253..661360d6 100644
--- a/pkg/_fe_analyzer_shared/analysis_options.yaml
+++ b/pkg/_fe_analyzer_shared/analysis_options.yaml
@@ -18,3 +18,4 @@
- package_api_docs
- lines_longer_than_80_chars
# - always_specify_types
+ - use_super_parameters
diff --git a/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart b/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
index 654ab4a..d91b11e 100644
--- a/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
@@ -1032,6 +1032,10 @@
class FlowAnalysisDebug<Node extends Object, Statement extends Node,
Expression extends Object, Variable extends Object, Type extends Object>
implements FlowAnalysis<Node, Statement, Expression, Variable, Type> {
+ static int _nextCallbackId = 0;
+
+ static Expando<String> _description = new Expando<String>();
+
FlowAnalysis<Node, Statement, Expression, Variable, Type> _wrapped;
bool _exceptionOccurred = false;
@@ -1538,16 +1542,18 @@
@override
Map<Type, NonPromotionReason> Function() whyNotPromoted(Expression target) {
- return _wrap(
- 'whyNotPromoted($target)', () => _wrapped.whyNotPromoted(target),
+ return _wrap('whyNotPromoted($target)',
+ () => _trackWhyNotPromoted(_wrapped.whyNotPromoted(target)),
isQuery: true);
}
@override
Map<Type, NonPromotionReason> Function() whyNotPromotedImplicitThis(
Type staticType) {
- return _wrap('whyNotPromotedImplicitThis($staticType)',
- () => _wrapped.whyNotPromotedImplicitThis(staticType),
+ return _wrap(
+ 'whyNotPromotedImplicitThis($staticType)',
+ () => _trackWhyNotPromoted(
+ _wrapped.whyNotPromotedImplicitThis(staticType)),
isQuery: true);
}
@@ -1561,6 +1567,19 @@
@override
void _dumpState() => _wrapped._dumpState();
+ /// Wraps [callback] so that when it is called, the call (and its return
+ /// value) will be printed to the console. Also registers the wrapped
+ /// callback in [_description] so that it will be given a unique identifier
+ /// when printed to the console.
+ Map<Type, NonPromotionReason> Function() _trackWhyNotPromoted(
+ Map<Type, NonPromotionReason> Function() callback) {
+ String callbackToString = '#CALLBACK${_nextCallbackId++}';
+ Map<Type, NonPromotionReason> Function() wrappedCallback =
+ () => _wrap('$callbackToString()', callback, isQuery: true);
+ _description[wrappedCallback] = callbackToString;
+ return wrappedCallback;
+ }
+
T _wrap<T>(String description, T callback(),
{bool isQuery: false, bool? isPure}) {
isPure ??= isQuery;
@@ -1578,10 +1597,18 @@
_wrapped._dumpState();
}
if (isQuery) {
- print(' => $result');
+ print(' => ${_describe(result)}');
}
return result;
}
+
+ static String _describe(Object? value) {
+ if (value != null && value is! String && value is! num && value is! bool) {
+ String? description = _description[value];
+ if (description != null) return description;
+ }
+ return value.toString();
+ }
}
/// An instance of the [FlowModel] class represents the information gathered by
@@ -2613,6 +2640,9 @@
final Type type;
ReferenceWithType(this.reference, this.type);
+
+ @override
+ String toString() => 'ReferenceWithType($reference, $type)';
}
/// Data structure representing a unique value that a variable might take on
@@ -2859,6 +2889,9 @@
if (nonPromotionHistory != null) {
parts.add('nonPromotionHistory: $nonPromotionHistory');
}
+ if (properties.isNotEmpty) {
+ parts.add('properties: $properties');
+ }
return 'VariableModel(${parts.join(', ')})';
}
@@ -3358,6 +3391,9 @@
}
@override
+ String toString() => 'VariableReference($variable)';
+
+ @override
VariableModel<Variable, Type>? _getInfo(
Map<Variable?, VariableModel<Variable, Type>> variableInfo) =>
variableInfo[variable];
@@ -3371,7 +3407,7 @@
/// Flow models associated with the condition being asserted.
ExpressionInfo<Variable, Type>? _conditionInfo;
- _AssertContext(FlowModel<Variable, Type> previous) : super(previous);
+ _AssertContext(super.previous);
@override
String toString() =>
@@ -3424,8 +3460,7 @@
/// circumstance where the "then" branch is taken.
ExpressionInfo<Variable, Type>? _thenInfo;
- _ConditionalContext(ExpressionInfo<Variable, Type> conditionInfo)
- : super(conditionInfo);
+ _ConditionalContext(ExpressionInfo<Variable, Type> super.conditionInfo);
@override
String toString() => '_ConditionalContext(conditionInfo: $_conditionInfo, '
@@ -4353,8 +4388,7 @@
/// [_FlowContext] representing a function expression.
class _FunctionExpressionContext<Variable extends Object, Type extends Object>
extends _SimpleContext<Variable, Type> {
- _FunctionExpressionContext(FlowModel<Variable, Type> previous)
- : super(previous);
+ _FunctionExpressionContext(super.previous);
@override
String toString() => '_FunctionExpressionContext(previous: $_previous)';
@@ -4367,8 +4401,7 @@
/// statement executes, in the circumstance where the "then" branch is taken.
FlowModel<Variable, Type>? _afterThen;
- _IfContext(ExpressionInfo<Variable, Type> conditionInfo)
- : super(conditionInfo);
+ _IfContext(ExpressionInfo<Variable, Type> super.conditionInfo);
@override
String toString() =>
@@ -4378,8 +4411,7 @@
/// [_FlowContext] representing an "if-null" (`??`) expression.
class _IfNullExpressionContext<Variable extends Object, Type extends Object>
extends _SimpleContext<Variable, Type> {
- _IfNullExpressionContext(FlowModel<Variable, Type> previous)
- : super(previous);
+ _IfNullExpressionContext(super.previous);
@override
String toString() => '_IfNullExpressionContext(previous: $_previous)';
@@ -4396,9 +4428,8 @@
/// expression.
final AssignedVariablesNodeInfo<Variable> _assignedVariablesInfoForRhs;
- _LegacyBinaryAndContext(Map<Variable, Type> previousKnownTypes,
- this._lhsShownTypes, this._assignedVariablesInfoForRhs)
- : super(previousKnownTypes);
+ _LegacyBinaryAndContext(super.previousKnownTypes, this._lhsShownTypes,
+ this._assignedVariablesInfoForRhs);
}
/// Contextual information tracked by legacy type promotion about a statement or
@@ -4947,7 +4978,7 @@
/// [_FlowContext] representing a null aware access (`?.`).
class _NullAwareAccessContext<Variable extends Object, Type extends Object>
extends _SimpleContext<Variable, Type> {
- _NullAwareAccessContext(FlowModel<Variable, Type> previous) : super(previous);
+ _NullAwareAccessContext(super.previous);
@override
String toString() => '_NullAwareAccessContext(previous: $_previous)';
@@ -5031,6 +5062,10 @@
}
@override
+ String toString() =>
+ '_PropertyGetReference($target, $propertyName, $propertyMember)';
+
+ @override
VariableModel<Variable, Type>? _getInfo(
Map<Variable?, VariableModel<Variable, Type>> variableInfo) {
VariableModel<Variable, Type> targetInfo = target.getInfo(variableInfo);
@@ -5064,8 +5099,7 @@
/// after evaluation of the switch expression.
final FlowModel<Variable, Type> _previous;
- _SimpleStatementContext(Reachability checkpoint, this._previous)
- : super(checkpoint);
+ _SimpleStatementContext(super.checkpoint, this._previous);
@override
String toString() => '_SimpleStatementContext(breakModel: $_breakModel, '
@@ -5146,7 +5180,7 @@
/// has finished executing.
FlowModel<Variable, Type>? _afterBodyAndCatches;
- _TryContext(FlowModel<Variable, Type> previous) : super(previous);
+ _TryContext(super.previous);
@override
String toString() =>
@@ -5160,7 +5194,7 @@
/// block.
late final FlowModel<Variable, Type> _beforeFinally;
- _TryFinallyContext(FlowModel<Variable, Type> previous) : super(previous);
+ _TryFinallyContext(super.previous);
}
/// [_FlowContext] representing a `while` loop (or a C-style `for` loop, which
@@ -5170,8 +5204,7 @@
/// Flow models associated with the loop condition.
final ExpressionInfo<Variable, Type> _conditionInfo;
- _WhileContext(Reachability checkpoint, this._conditionInfo)
- : super(checkpoint);
+ _WhileContext(super.checkpoint, this._conditionInfo);
@override
String toString() => '_WhileContext(breakModel: $_breakModel, '
diff --git a/pkg/_fe_analyzer_shared/lib/src/macros/api/code.dart b/pkg/_fe_analyzer_shared/lib/src/macros/api/code.dart
index fc67ba8..9ae76ec 100644
--- a/pkg/_fe_analyzer_shared/lib/src/macros/api/code.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/macros/api/code.dart
@@ -27,9 +27,9 @@
@override
CodeKind get kind => CodeKind.declaration;
- DeclarationCode.fromString(String code) : super.fromString(code);
+ DeclarationCode.fromString(super.code) : super.fromString();
- DeclarationCode.fromParts(List<Object> parts) : super.fromParts(parts);
+ DeclarationCode.fromParts(super.parts) : super.fromParts();
}
/// A piece of code representing a syntactically valid expression.
@@ -37,9 +37,9 @@
@override
CodeKind get kind => CodeKind.expression;
- ExpressionCode.fromString(String code) : super.fromString(code);
+ ExpressionCode.fromString(super.code) : super.fromString();
- ExpressionCode.fromParts(List<Object> parts) : super.fromParts(parts);
+ ExpressionCode.fromParts(super.parts) : super.fromParts();
}
/// A piece of code representing a syntactically valid function body.
@@ -52,9 +52,9 @@
@override
CodeKind get kind => CodeKind.functionBody;
- FunctionBodyCode.fromString(String code) : super.fromString(code);
+ FunctionBodyCode.fromString(super.code) : super.fromString();
- FunctionBodyCode.fromParts(List<Object> parts) : super.fromParts(parts);
+ FunctionBodyCode.fromParts(super.parts) : super.fromParts();
}
/// A piece of code identifying a syntactically valid function or function type
diff --git a/pkg/_fe_analyzer_shared/lib/src/macros/executor/builder_impls.dart b/pkg/_fe_analyzer_shared/lib/src/macros/executor/builder_impls.dart
index f830cde..6272069 100644
--- a/pkg/_fe_analyzer_shared/lib/src/macros/executor/builder_impls.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/macros/executor/builder_impls.dart
@@ -43,8 +43,7 @@
}
class TypeBuilderImpl extends TypeBuilderBase implements TypeBuilder {
- TypeBuilderImpl(IdentifierResolver identifierResolver)
- : super(identifierResolver);
+ TypeBuilderImpl(super.identifierResolver);
@override
void declareType(String name, DeclarationCode typeDeclaration) {
@@ -60,13 +59,9 @@
final TypeDeclarationResolver typeDeclarationResolver;
final TypeResolver typeResolver;
- DeclarationBuilderBase(IdentifierResolver identifierResolver,
- this.typeIntrospector, this.typeDeclarationResolver, this.typeResolver,
- {Map<String, List<DeclarationCode>>? parentClassAugmentations,
- List<DeclarationCode>? parentLibraryAugmentations})
- : super(identifierResolver,
- parentClassAugmentations: parentClassAugmentations,
- parentLibraryAugmentations: parentLibraryAugmentations);
+ DeclarationBuilderBase(super.identifierResolver, this.typeIntrospector,
+ this.typeDeclarationResolver, this.typeResolver,
+ {super.parentClassAugmentations, super.parentLibraryAugmentations});
@override
Future<TypeDeclaration> declarationOf(IdentifierImpl identifier) =>
@@ -94,13 +89,8 @@
class DeclarationBuilderImpl extends DeclarationBuilderBase
implements DeclarationBuilder {
- DeclarationBuilderImpl(
- IdentifierResolver identifierResolver,
- TypeIntrospector typeIntrospector,
- TypeDeclarationResolver typeDeclarationResolver,
- TypeResolver typeResolver)
- : super(identifierResolver, typeIntrospector, typeDeclarationResolver,
- typeResolver);
+ DeclarationBuilderImpl(super.identifierResolver, super.typeIntrospector,
+ super.typeDeclarationResolver, super.typeResolver);
@override
void declareInLibrary(DeclarationCode declaration) {
@@ -134,18 +124,9 @@
implements TypeInferrer {
final TypeInferrer typeInferrer;
- DefinitionBuilderBase(
- IdentifierResolver identifierResolver,
- TypeIntrospector typeIntrospector,
- TypeDeclarationResolver typeDeclarationResolver,
- TypeResolver typeResolver,
- this.typeInferrer,
- {Map<String, List<DeclarationCode>>? parentClassAugmentations,
- List<DeclarationCode>? parentLibraryAugmentations})
- : super(identifierResolver, typeIntrospector, typeDeclarationResolver,
- typeResolver,
- parentClassAugmentations: parentClassAugmentations,
- parentLibraryAugmentations: parentLibraryAugmentations);
+ DefinitionBuilderBase(super.identifierResolver, super.typeIntrospector,
+ super.typeDeclarationResolver, super.typeResolver, this.typeInferrer,
+ {super.parentClassAugmentations, super.parentLibraryAugmentations});
@override
Future<TypeAnnotation> inferType(OmittedTypeAnnotationImpl omittedType) =>
diff --git a/pkg/_fe_analyzer_shared/lib/src/macros/executor/introspection_impls.dart b/pkg/_fe_analyzer_shared/lib/src/macros/executor/introspection_impls.dart
index 903c48c..f001456 100644
--- a/pkg/_fe_analyzer_shared/lib/src/macros/executor/introspection_impls.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/macros/executor/introspection_impls.dart
@@ -62,11 +62,11 @@
RemoteInstanceKind get kind => RemoteInstanceKind.namedTypeAnnotation;
NamedTypeAnnotationImpl({
- required int id,
- required bool isNullable,
+ required super.id,
+ required super.isNullable,
required this.identifier,
required this.typeArguments,
- }) : super(id: id, isNullable: isNullable);
+ });
@override
void serialize(Serializer serializer) {
@@ -120,13 +120,13 @@
RemoteInstanceKind get kind => RemoteInstanceKind.functionTypeAnnotation;
FunctionTypeAnnotationImpl({
- required int id,
- required bool isNullable,
+ required super.id,
+ required super.isNullable,
required this.namedParameters,
required this.positionalParameters,
required this.returnType,
required this.typeParameters,
- }) : super(id: id, isNullable: isNullable);
+ });
@override
void serialize(Serializer serializer) {
@@ -158,8 +158,7 @@
class OmittedTypeAnnotationImpl extends TypeAnnotationImpl
implements OmittedTypeAnnotation {
- OmittedTypeAnnotationImpl({required int id})
- : super(id: id, isNullable: false);
+ OmittedTypeAnnotationImpl({required super.id}) : super(isNullable: false);
@override
TypeAnnotationCode get code => new OmittedTypeAnnotationCode(this);
@@ -198,12 +197,12 @@
RemoteInstanceKind get kind => RemoteInstanceKind.parameterDeclaration;
ParameterDeclarationImpl({
- required int id,
- required IdentifierImpl identifier,
+ required super.id,
+ required super.identifier,
required this.isNamed,
required this.isRequired,
required this.type,
- }) : super(id: id, identifier: identifier);
+ });
@override
void serialize(Serializer serializer) {
@@ -276,10 +275,10 @@
RemoteInstanceKind get kind => RemoteInstanceKind.typeParameterDeclaration;
TypeParameterDeclarationImpl({
- required int id,
- required IdentifierImpl identifier,
+ required super.id,
+ required super.identifier,
required this.bound,
- }) : super(id: id, identifier: identifier);
+ });
@override
void serialize(Serializer serializer) {
@@ -333,8 +332,8 @@
RemoteInstanceKind get kind => RemoteInstanceKind.functionDeclaration;
FunctionDeclarationImpl({
- required int id,
- required IdentifierImpl identifier,
+ required super.id,
+ required super.identifier,
required this.isAbstract,
required this.isExternal,
required this.isGetter,
@@ -344,7 +343,7 @@
required this.positionalParameters,
required this.returnType,
required this.typeParameters,
- }) : super(id: id, identifier: identifier);
+ });
@override
void serialize(Serializer serializer) {
@@ -391,34 +390,22 @@
MethodDeclarationImpl({
// Declaration fields
- required int id,
- required IdentifierImpl identifier,
+ required super.id,
+ required super.identifier,
// Function fields
- required bool isAbstract,
- required bool isExternal,
- required bool isGetter,
- required bool isOperator,
- required bool isSetter,
- required List<ParameterDeclarationImpl> namedParameters,
- required List<ParameterDeclarationImpl> positionalParameters,
- required TypeAnnotationImpl returnType,
- required List<TypeParameterDeclarationImpl> typeParameters,
+ required super.isAbstract,
+ required super.isExternal,
+ required super.isGetter,
+ required super.isOperator,
+ required super.isSetter,
+ required super.namedParameters,
+ required super.positionalParameters,
+ required super.returnType,
+ required super.typeParameters,
// Method fields
required this.definingClass,
required this.isStatic,
- }) : super(
- id: id,
- identifier: identifier,
- isAbstract: isAbstract,
- isExternal: isExternal,
- isGetter: isGetter,
- isOperator: isOperator,
- isSetter: isSetter,
- namedParameters: namedParameters,
- positionalParameters: positionalParameters,
- returnType: returnType,
- typeParameters: typeParameters,
- );
+ });
@override
void serialize(Serializer serializer) {
@@ -441,35 +428,23 @@
ConstructorDeclarationImpl({
// Declaration fields
- required int id,
- required IdentifierImpl identifier,
+ required super.id,
+ required super.identifier,
// Function fields
- required bool isAbstract,
- required bool isExternal,
- required bool isGetter,
- required bool isOperator,
- required bool isSetter,
- required List<ParameterDeclarationImpl> namedParameters,
- required List<ParameterDeclarationImpl> positionalParameters,
- required TypeAnnotationImpl returnType,
- required List<TypeParameterDeclarationImpl> typeParameters,
+ required super.isAbstract,
+ required super.isExternal,
+ required super.isGetter,
+ required super.isOperator,
+ required super.isSetter,
+ required super.namedParameters,
+ required super.positionalParameters,
+ required super.returnType,
+ required super.typeParameters,
// Method fields
- required IdentifierImpl definingClass,
+ required super.definingClass,
// Constructor fields
required this.isFactory,
}) : super(
- id: id,
- identifier: identifier,
- isAbstract: isAbstract,
- isExternal: isExternal,
- isGetter: isGetter,
- isOperator: isOperator,
- isSetter: isSetter,
- namedParameters: namedParameters,
- positionalParameters: positionalParameters,
- returnType: returnType,
- typeParameters: typeParameters,
- definingClass: definingClass,
isStatic: true,
);
@@ -501,13 +476,13 @@
RemoteInstanceKind get kind => RemoteInstanceKind.variableDeclaration;
VariableDeclarationImpl({
- required int id,
- required IdentifierImpl identifier,
+ required super.id,
+ required super.identifier,
required this.isExternal,
required this.isFinal,
required this.isLate,
required this.type,
- }) : super(id: id, identifier: identifier);
+ });
@override
void serialize(Serializer serializer) {
@@ -533,23 +508,17 @@
FieldDeclarationImpl({
// Declaration fields
- required int id,
- required IdentifierImpl identifier,
+ required super.id,
+ required super.identifier,
// Variable fields
- required bool isExternal,
- required bool isFinal,
- required bool isLate,
- required TypeAnnotationImpl type,
+ required super.isExternal,
+ required super.isFinal,
+ required super.isLate,
+ required super.type,
// Field fields
required this.definingClass,
required this.isStatic,
- }) : super(
- id: id,
- identifier: identifier,
- isExternal: isExternal,
- isFinal: isFinal,
- isLate: isLate,
- type: type);
+ });
@override
RemoteInstanceKind get kind => RemoteInstanceKind.fieldDeclaration;
@@ -570,10 +539,10 @@
final List<TypeParameterDeclarationImpl> typeParameters;
ParameterizedTypeDeclarationImpl({
- required int id,
- required IdentifierImpl identifier,
+ required super.id,
+ required super.identifier,
required this.typeParameters,
- }) : super(id: id, identifier: identifier);
+ });
void serialize(Serializer serializer) {
super.serialize(serializer);
@@ -616,17 +585,17 @@
ClassDeclarationImpl({
// Declaration fields
- required int id,
- required IdentifierImpl identifier,
+ required super.id,
+ required super.identifier,
// TypeDeclaration fields
- required List<TypeParameterDeclarationImpl> typeParameters,
+ required super.typeParameters,
// ClassDeclaration fields
required this.interfaces,
required this.isAbstract,
required this.isExternal,
required this.mixins,
required this.superclass,
- }) : super(id: id, identifier: identifier, typeParameters: typeParameters);
+ });
@override
void serialize(Serializer serializer) {
@@ -661,13 +630,13 @@
TypeAliasDeclarationImpl({
// Declaration fields
- required int id,
- required IdentifierImpl identifier,
+ required super.id,
+ required super.identifier,
// TypeDeclaration fields
- required List<TypeParameterDeclarationImpl> typeParameters,
+ required super.typeParameters,
// TypeAlias fields
required this.aliasedType,
- }) : super(id: id, identifier: identifier, typeParameters: typeParameters);
+ });
@override
void serialize(Serializer serializer) {
diff --git a/pkg/_fe_analyzer_shared/lib/src/macros/executor/isolated_executor.dart b/pkg/_fe_analyzer_shared/lib/src/macros/executor/isolated_executor.dart
index 35facb9..6aefda5 100644
--- a/pkg/_fe_analyzer_shared/lib/src/macros/executor/isolated_executor.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/macros/executor/isolated_executor.dart
@@ -37,12 +37,10 @@
final void Function() onClose;
_SingleIsolatedMacroExecutor(
- {required Stream<Object> messageStream,
+ {required super.messageStream,
required this.onClose,
required this.sendPort,
- required SerializationMode serializationMode})
- : super(
- messageStream: messageStream, serializationMode: serializationMode);
+ required super.serializationMode});
static Future<_SingleIsolatedMacroExecutor> start(
Uri uriToSpawn,
diff --git a/pkg/_fe_analyzer_shared/lib/src/macros/executor/process_executor.dart b/pkg/_fe_analyzer_shared/lib/src/macros/executor/process_executor.dart
index 01d4004..eda515f 100644
--- a/pkg/_fe_analyzer_shared/lib/src/macros/executor/process_executor.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/macros/executor/process_executor.dart
@@ -44,12 +44,10 @@
final void Function() onClose;
_SingleProcessMacroExecutor(
- {required Stream<Object> messageStream,
+ {required super.messageStream,
required this.onClose,
required this.outSink,
- required SerializationMode serializationMode})
- : super(
- messageStream: messageStream, serializationMode: serializationMode);
+ required super.serializationMode});
static Future<_SingleProcessMacroExecutor> startWithSocket(
SerializationMode serializationMode,
diff --git a/pkg/_fe_analyzer_shared/lib/src/macros/executor/protocol.dart b/pkg/_fe_analyzer_shared/lib/src/macros/executor/protocol.dart
index 26c47bf..5cf95cc 100644
--- a/pkg/_fe_analyzer_shared/lib/src/macros/executor/protocol.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/macros/executor/protocol.dart
@@ -195,14 +195,13 @@
final Uri library;
final String name;
- LoadMacroRequest(this.library, this.name, {required int serializationZoneId})
- : super(serializationZoneId: serializationZoneId);
+ LoadMacroRequest(this.library, this.name,
+ {required super.serializationZoneId});
- LoadMacroRequest.deserialize(
- Deserializer deserializer, int serializationZoneId)
+ LoadMacroRequest.deserialize(super.deserializer, super.serializationZoneId)
: library = Uri.parse((deserializer..moveNext()).expectString()),
name = (deserializer..moveNext()).expectString(),
- super.deserialize(deserializer, serializationZoneId);
+ super.deserialize();
@override
void serialize(Serializer serializer) {
@@ -227,17 +226,16 @@
InstantiateMacroRequest(this.library, this.name, this.constructor,
this.arguments, this.instanceId,
- {required int serializationZoneId})
- : super(serializationZoneId: serializationZoneId);
+ {required super.serializationZoneId});
InstantiateMacroRequest.deserialize(
- Deserializer deserializer, int serializationZoneId)
+ super.deserializer, super.serializationZoneId)
: library = (deserializer..moveNext()).expectUri(),
name = (deserializer..moveNext()).expectString(),
constructor = (deserializer..moveNext()).expectString(),
arguments = new Arguments.deserialize(deserializer),
instanceId = (deserializer..moveNext()).expectInt(),
- super.deserialize(deserializer, serializationZoneId);
+ super.deserialize();
@override
void serialize(Serializer serializer) {
@@ -260,17 +258,16 @@
ExecuteTypesPhaseRequest(
this.macro, this.declaration, this.identifierResolver,
- {required int serializationZoneId})
- : super(serializationZoneId: serializationZoneId);
+ {required super.serializationZoneId});
/// When deserializing we have already consumed the message type, so we don't
/// consume it again.
ExecuteTypesPhaseRequest.deserialize(
- Deserializer deserializer, int serializationZoneId)
+ super.deserializer, super.serializationZoneId)
: macro = new MacroInstanceIdentifierImpl.deserialize(deserializer),
declaration = RemoteInstance.deserialize(deserializer),
identifierResolver = RemoteInstance.deserialize(deserializer),
- super.deserialize(deserializer, serializationZoneId);
+ super.deserialize();
void serialize(Serializer serializer) {
serializer.addInt(MessageType.executeTypesPhaseRequest.index);
@@ -300,20 +297,19 @@
this.typeDeclarationResolver,
this.typeResolver,
this.typeIntrospector,
- {required int serializationZoneId})
- : super(serializationZoneId: serializationZoneId);
+ {required super.serializationZoneId});
/// When deserializing we have already consumed the message type, so we don't
/// consume it again.
ExecuteDeclarationsPhaseRequest.deserialize(
- Deserializer deserializer, int serializationZoneId)
+ super.deserializer, super.serializationZoneId)
: macro = new MacroInstanceIdentifierImpl.deserialize(deserializer),
declaration = RemoteInstance.deserialize(deserializer),
identifierResolver = RemoteInstance.deserialize(deserializer),
typeDeclarationResolver = RemoteInstance.deserialize(deserializer),
typeResolver = RemoteInstance.deserialize(deserializer),
typeIntrospector = RemoteInstance.deserialize(deserializer),
- super.deserialize(deserializer, serializationZoneId);
+ super.deserialize();
void serialize(Serializer serializer) {
serializer.addInt(MessageType.executeDeclarationsPhaseRequest.index);
@@ -348,13 +344,12 @@
this.typeIntrospector,
this.typeDeclarationResolver,
this.typeInferrer,
- {required int serializationZoneId})
- : super(serializationZoneId: serializationZoneId);
+ {required super.serializationZoneId});
/// When deserializing we have already consumed the message type, so we don't
/// consume it again.
ExecuteDefinitionsPhaseRequest.deserialize(
- Deserializer deserializer, int serializationZoneId)
+ super.deserializer, super.serializationZoneId)
: macro = new MacroInstanceIdentifierImpl.deserialize(deserializer),
declaration = RemoteInstance.deserialize(deserializer),
identifierResolver = RemoteInstance.deserialize(deserializer),
@@ -362,7 +357,7 @@
typeIntrospector = RemoteInstance.deserialize(deserializer),
typeDeclarationResolver = RemoteInstance.deserialize(deserializer),
typeInferrer = RemoteInstance.deserialize(deserializer),
- super.deserialize(deserializer, serializationZoneId);
+ super.deserialize();
void serialize(Serializer serializer) {
serializer.addInt(MessageType.executeDefinitionsPhaseRequest.index);
@@ -388,15 +383,14 @@
/// When deserializing we have already consumed the message type, so we don't
/// consume it again.
ResolveIdentifierRequest(this.library, this.name, this.identifierResolver,
- {required int serializationZoneId})
- : super(serializationZoneId: serializationZoneId);
+ {required super.serializationZoneId});
ResolveIdentifierRequest.deserialize(
- Deserializer deserializer, int serializationZoneId)
+ super.deserializer, super.serializationZoneId)
: library = Uri.parse((deserializer..moveNext()).expectString()),
name = (deserializer..moveNext()).expectString(),
identifierResolver = RemoteInstance.deserialize(deserializer),
- super.deserialize(deserializer, serializationZoneId);
+ super.deserialize();
void serialize(Serializer serializer) {
serializer
@@ -415,16 +409,14 @@
final RemoteInstanceImpl typeResolver;
ResolveTypeRequest(this.typeAnnotationCode, this.typeResolver,
- {required int serializationZoneId})
- : super(serializationZoneId: serializationZoneId);
+ {required super.serializationZoneId});
/// When deserializing we have already consumed the message type, so we don't
/// consume it again.
- ResolveTypeRequest.deserialize(
- Deserializer deserializer, int serializationZoneId)
+ ResolveTypeRequest.deserialize(super.deserializer, super.serializationZoneId)
: typeAnnotationCode = (deserializer..moveNext()).expectCode(),
typeResolver = RemoteInstance.deserialize(deserializer),
- super.deserialize(deserializer, serializationZoneId);
+ super.deserialize();
void serialize(Serializer serializer) {
serializer.addInt(MessageType.resolveTypeRequest.index);
@@ -440,16 +432,15 @@
final RemoteInstanceImpl rightType;
IsExactlyTypeRequest(this.leftType, this.rightType,
- {required int serializationZoneId})
- : super(serializationZoneId: serializationZoneId);
+ {required super.serializationZoneId});
/// When deserializing we have already consumed the message type, so we don't
/// consume it again.
IsExactlyTypeRequest.deserialize(
- Deserializer deserializer, int serializationZoneId)
+ super.deserializer, super.serializationZoneId)
: leftType = RemoteInstance.deserialize(deserializer),
rightType = RemoteInstance.deserialize(deserializer),
- super.deserialize(deserializer, serializationZoneId);
+ super.deserialize();
void serialize(Serializer serializer) {
serializer.addInt(MessageType.isExactlyTypeRequest.index);
@@ -465,16 +456,14 @@
final RemoteInstanceImpl rightType;
IsSubtypeOfRequest(this.leftType, this.rightType,
- {required int serializationZoneId})
- : super(serializationZoneId: serializationZoneId);
+ {required super.serializationZoneId});
/// When deserializing we have already consumed the message type, so we don't
/// consume it again.
- IsSubtypeOfRequest.deserialize(
- Deserializer deserializer, int serializationZoneId)
+ IsSubtypeOfRequest.deserialize(super.deserializer, super.serializationZoneId)
: leftType = RemoteInstance.deserialize(deserializer),
rightType = RemoteInstance.deserialize(deserializer),
- super.deserialize(deserializer, serializationZoneId);
+ super.deserialize();
void serialize(Serializer serializer) {
serializer.addInt(MessageType.isSubtypeOfRequest.index);
@@ -493,8 +482,7 @@
InterfaceIntrospectionRequest(
this.type, this.typeIntrospector, this.requestKind,
- {required int serializationZoneId})
- : super(serializationZoneId: serializationZoneId);
+ {required super.serializationZoneId});
/// When deserializing we have already consumed the message type, so we don't
/// consume it again and it should instead be passed in here.
@@ -519,16 +507,15 @@
final RemoteInstanceImpl typeDeclarationResolver;
DeclarationOfRequest(this.identifier, this.typeDeclarationResolver,
- {required int serializationZoneId})
- : super(serializationZoneId: serializationZoneId);
+ {required super.serializationZoneId});
/// When deserializing we have already consumed the message type, so we don't
/// consume it again.
DeclarationOfRequest.deserialize(
- Deserializer deserializer, int serializationZoneId)
+ super.deserializer, super.serializationZoneId)
: identifier = RemoteInstance.deserialize(deserializer),
typeDeclarationResolver = RemoteInstance.deserialize(deserializer),
- super.deserialize(deserializer, serializationZoneId);
+ super.deserialize();
@override
void serialize(Serializer serializer) {
@@ -546,16 +533,14 @@
final RemoteInstanceImpl typeInferrer;
InferTypeRequest(this.omittedType, this.typeInferrer,
- {required int serializationZoneId})
- : super(serializationZoneId: serializationZoneId);
+ {required super.serializationZoneId});
/// When deserializing we have already consumed the message type, so we don't
/// consume it again.
- InferTypeRequest.deserialize(
- Deserializer deserializer, int serializationZoneId)
+ InferTypeRequest.deserialize(super.deserializer, super.serializationZoneId)
: omittedType = RemoteInstance.deserialize(deserializer),
typeInferrer = RemoteInstance.deserialize(deserializer),
- super.deserialize(deserializer, serializationZoneId);
+ super.deserialize();
@override
void serialize(Serializer serializer) {
@@ -666,13 +651,8 @@
/// Named variant of the [ClientStaticTypeImpl].
class ClientNamedStaticTypeImpl extends ClientStaticTypeImpl
implements NamedStaticType {
- ClientNamedStaticTypeImpl(
- Future<Response> Function(Request request) sendRequest,
- {required RemoteInstanceImpl remoteInstance,
- required int serializationZoneId})
- : super(sendRequest,
- remoteInstance: remoteInstance,
- serializationZoneId: serializationZoneId);
+ ClientNamedStaticTypeImpl(super.sendRequest,
+ {required super.remoteInstance, required super.serializationZoneId});
}
/// Client side implementation of the [ClientTypeIntrospector], converts
diff --git a/pkg/_fe_analyzer_shared/lib/src/messages/codes.dart b/pkg/_fe_analyzer_shared/lib/src/messages/codes.dart
index 5866409..202dad8 100644
--- a/pkg/_fe_analyzer_shared/lib/src/messages/codes.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/messages/codes.dart
@@ -68,14 +68,12 @@
final String? correctionMessage;
- const MessageCode(String name,
- {int index: -1,
- List<String>? analyzerCodes,
- Severity severity: Severity.error,
+ const MessageCode(super.name,
+ {super.index,
+ super.analyzerCodes,
+ super.severity,
required this.problemMessage,
- this.correctionMessage})
- : super(name,
- index: index, analyzerCodes: analyzerCodes, severity: severity);
+ this.correctionMessage});
Map<String, dynamic> get arguments => const <String, dynamic>{};
diff --git a/pkg/_fe_analyzer_shared/lib/src/parser/class_member_parser.dart b/pkg/_fe_analyzer_shared/lib/src/parser/class_member_parser.dart
index d83d3a0..f53db77 100644
--- a/pkg/_fe_analyzer_shared/lib/src/parser/class_member_parser.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/parser/class_member_parser.dart
@@ -8,8 +8,6 @@
import 'error_delegation_listener.dart' show ErrorDelegationListener;
-import 'listener.dart' show Listener;
-
import 'parser_impl.dart' show Parser;
/// Parser similar to [TopLevelParser] but also parses class members (excluding
@@ -17,10 +15,7 @@
class ClassMemberParser extends Parser {
Parser? skipParser;
- ClassMemberParser(Listener listener,
- {bool useImplicitCreationExpression: true})
- : super(listener,
- useImplicitCreationExpression: useImplicitCreationExpression);
+ ClassMemberParser(super.listener, {super.useImplicitCreationExpression});
@override
Token parseExpression(Token token) {
diff --git a/pkg/_fe_analyzer_shared/lib/src/parser/identifier_context_impl.dart b/pkg/_fe_analyzer_shared/lib/src/parser/identifier_context_impl.dart
index 4621543..979d161 100644
--- a/pkg/_fe_analyzer_shared/lib/src/parser/identifier_context_impl.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/parser/identifier_context_impl.dart
@@ -1025,8 +1025,8 @@
class TopLevelDeclarationIdentifierContext extends IdentifierContext {
final List<String> followingValues;
- const TopLevelDeclarationIdentifierContext(String name, this.followingValues)
- : super(name, inDeclaration: true);
+ const TopLevelDeclarationIdentifierContext(super.name, this.followingValues)
+ : super(inDeclaration: true);
@override
Token ensureIdentifier(Token token, Parser parser) {
diff --git a/pkg/_fe_analyzer_shared/lib/src/parser/top_level_parser.dart b/pkg/_fe_analyzer_shared/lib/src/parser/top_level_parser.dart
index 5399b86..14f69b4 100644
--- a/pkg/_fe_analyzer_shared/lib/src/parser/top_level_parser.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/parser/top_level_parser.dart
@@ -10,14 +10,10 @@
import 'class_member_parser.dart' show ClassMemberParser;
-import 'listener.dart' show Listener;
-
/// Parser which only parses top-level elements, but ignores their bodies.
/// Use [Parser] to parse everything.
class TopLevelParser extends ClassMemberParser {
- TopLevelParser(Listener listener, {bool useImplicitCreationExpression: true})
- : super(listener,
- useImplicitCreationExpression: useImplicitCreationExpression);
+ TopLevelParser(super.listener, {super.useImplicitCreationExpression});
@override
Token parseClassOrMixinOrExtensionBody(Token token, DeclarationKind kind,
diff --git a/pkg/_fe_analyzer_shared/lib/src/scanner/error_token.dart b/pkg/_fe_analyzer_shared/lib/src/scanner/error_token.dart
index 824d170..f8ab292 100644
--- a/pkg/_fe_analyzer_shared/lib/src/scanner/error_token.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/scanner/error_token.dart
@@ -105,7 +105,7 @@
/// Represents an encoding error.
class EncodingErrorToken extends ErrorToken {
- EncodingErrorToken(int charOffset) : super(charOffset);
+ EncodingErrorToken(super.charOffset);
String toString() => "EncodingErrorToken()";
diff --git a/pkg/_fe_analyzer_shared/lib/src/scanner/errors.dart b/pkg/_fe_analyzer_shared/lib/src/scanner/errors.dart
index 44cdf31..efb594a 100644
--- a/pkg/_fe_analyzer_shared/lib/src/scanner/errors.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/scanner/errors.dart
@@ -184,9 +184,8 @@
* given [correctionMessage] template.
*/
const ScannerErrorCode(String name, String problemMessage,
- {String? correctionMessage})
+ {super.correctionMessage})
: super(
- correctionMessage: correctionMessage,
problemMessage: problemMessage,
name: name,
uniqueName: 'ScannerErrorCode.$name',
diff --git a/pkg/_fe_analyzer_shared/lib/src/scanner/reader.dart b/pkg/_fe_analyzer_shared/lib/src/scanner/reader.dart
index 74c76f7..34f1084 100644
--- a/pkg/_fe_analyzer_shared/lib/src/scanner/reader.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/scanner/reader.dart
@@ -124,7 +124,7 @@
* [sequence]. The [_offsetDelta] is the offset from the beginning of the file
* to the beginning of the source being scanned
*/
- SubSequenceReader(String sequence, this._offsetDelta) : super(sequence);
+ SubSequenceReader(super.sequence, this._offsetDelta);
@override
int get offset => _offsetDelta + super.offset;
diff --git a/pkg/_fe_analyzer_shared/lib/src/scanner/string_scanner.dart b/pkg/_fe_analyzer_shared/lib/src/scanner/string_scanner.dart
index f31fbb1..96f953f 100644
--- a/pkg/_fe_analyzer_shared/lib/src/scanner/string_scanner.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/scanner/string_scanner.dart
@@ -44,10 +44,10 @@
: string = ensureZeroTermination(string),
super(configuration, includeComments, languageVersionChanged);
- StringScanner.recoveryOptionScanner(StringScanner copyFrom)
+ StringScanner.recoveryOptionScanner(StringScanner super.copyFrom)
: string = copyFrom.string,
scanOffset = copyFrom.scanOffset,
- super.recoveryOptionScanner(copyFrom);
+ super.recoveryOptionScanner();
StringScanner createRecoveryOptionScanner() {
return new StringScanner.recoveryOptionScanner(this);
diff --git a/pkg/_fe_analyzer_shared/lib/src/scanner/token.dart b/pkg/_fe_analyzer_shared/lib/src/scanner/token.dart
index 604b880..8b59e48 100644
--- a/pkg/_fe_analyzer_shared/lib/src/scanner/token.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/scanner/token.dart
@@ -78,8 +78,7 @@
* Initialize a newly created token to represent a token of the given [type]
* with the given [value] at the given [offset].
*/
- CommentToken(TokenType type, String value, int offset)
- : super(type, value, offset);
+ CommentToken(super.type, super.value, super.offset);
}
/**
@@ -90,8 +89,7 @@
* Initialize a newly created token to represent a token of the given [type]
* with the given [value] at the given [offset].
*/
- DocumentationCommentToken(TokenType type, String value, int offset)
- : super(type, value, offset);
+ DocumentationCommentToken(super.type, super.value, super.offset);
}
enum KeywordStyle {
@@ -655,10 +653,8 @@
* Initialize a newly created token to represent a token of the given [type]
* with the given [value] at the given [offset].
*/
- StringToken(TokenType type, String value, int offset,
- [CommentToken? precedingComment])
- : _value = StringUtilities.intern(value),
- super(type, offset, precedingComment);
+ StringToken(super.type, String value, super.offset, [super.precedingComment])
+ : _value = StringUtilities.intern(value);
@override
bool get isIdentifier => identical(kind, IDENTIFIER_TOKEN);
@@ -678,9 +674,7 @@
* Initialize a newly created token to have the given [type] at the given
* [offset].
*/
- SyntheticBeginToken(TokenType type, int offset,
- [CommentToken? precedingComment])
- : super(type, offset, precedingComment);
+ SyntheticBeginToken(super.type, super.offset, [super.precedingComment]);
@override
Token? beforeSynthetic;
@@ -700,7 +694,7 @@
* Initialize a newly created token to represent the given [keyword] at the
* given [offset].
*/
- SyntheticKeywordToken(Keyword keyword, int offset) : super(keyword, offset);
+ SyntheticKeywordToken(super.keyword, super.offset);
@override
Token? beforeSynthetic;
@@ -720,8 +714,7 @@
* with the given [value] at the given [offset]. If the [length] is
* not specified, then it defaults to the length of [value].
*/
- SyntheticStringToken(TokenType type, String value, int offset, [this._length])
- : super(type, value, offset);
+ SyntheticStringToken(super.type, super.value, super.offset, [this._length]);
@override
Token? beforeSynthetic;
@@ -737,7 +730,7 @@
* A synthetic token.
*/
class SyntheticToken extends SimpleToken {
- SyntheticToken(TokenType type, int offset) : super(type, offset);
+ SyntheticToken(super.type, super.offset);
@override
Token? beforeSynthetic;
diff --git a/pkg/_fe_analyzer_shared/lib/src/scanner/token_impl.dart b/pkg/_fe_analyzer_shared/lib/src/scanner/token_impl.dart
index 986340a..83f8484 100644
--- a/pkg/_fe_analyzer_shared/lib/src/scanner/token_impl.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/scanner/token_impl.dart
@@ -130,24 +130,23 @@
* is canonicalized before the token is created.
*/
CommentTokenImpl.fromSubstring(
- TokenType type, String data, int start, int end, int charOffset,
- {bool canonicalize: false})
- : super.fromSubstring(type, data, start, end, charOffset,
- canonicalize: canonicalize);
+ super.type, super.data, super.start, super.end, super.charOffset,
+ {super.canonicalize})
+ : super.fromSubstring();
/**
* Creates a non-lazy comment token.
*/
- CommentTokenImpl.fromString(TokenType type, String lexeme, int charOffset)
- : super.fromString(type, lexeme, charOffset);
+ CommentTokenImpl.fromString(super.type, super.lexeme, super.charOffset)
+ : super.fromString();
/**
* Creates a lazy string token. If [asciiOnly] is false, the byte array
* is passed through a UTF-8 decoder.
*/
- CommentTokenImpl.fromUtf8Bytes(TokenType type, List<int> data, int start,
- int end, bool asciiOnly, int charOffset)
- : super.fromUtf8Bytes(type, data, start, end, asciiOnly, charOffset);
+ CommentTokenImpl.fromUtf8Bytes(super.type, super.data, super.start, super.end,
+ super.asciiOnly, super.charOffset)
+ : super.fromUtf8Bytes();
}
class LanguageVersionTokenImpl extends CommentTokenImpl
@@ -181,18 +180,17 @@
* is canonicalized before the token is created.
*/
DartDocToken.fromSubstring(
- TokenType type, String data, int start, int end, int charOffset,
- {bool canonicalize: false})
- : super.fromSubstring(type, data, start, end, charOffset,
- canonicalize: canonicalize);
+ super.type, super.data, super.start, super.end, super.charOffset,
+ {super.canonicalize})
+ : super.fromSubstring();
/**
* Creates a lazy string token. If [asciiOnly] is false, the byte array
* is passed through a UTF-8 decoder.
*/
- DartDocToken.fromUtf8Bytes(TokenType type, List<int> data, int start, int end,
- bool asciiOnly, int charOffset)
- : super.fromUtf8Bytes(type, data, start, end, asciiOnly, charOffset);
+ DartDocToken.fromUtf8Bytes(super.type, super.data, super.start, super.end,
+ super.asciiOnly, super.charOffset)
+ : super.fromUtf8Bytes();
}
/**
diff --git a/pkg/_fe_analyzer_shared/pubspec.yaml b/pkg/_fe_analyzer_shared/pubspec.yaml
index ad5468c..d64e8b8 100644
--- a/pkg/_fe_analyzer_shared/pubspec.yaml
+++ b/pkg/_fe_analyzer_shared/pubspec.yaml
@@ -1,10 +1,10 @@
name: _fe_analyzer_shared
-version: 40.0.0
+version: 41.0.0
description: Logic that is shared between the front_end and analyzer packages.
repository: https://github.com/dart-lang/sdk/tree/main/pkg/_fe_analyzer_shared
environment:
- sdk: '>=2.12.0 <3.0.0'
+ sdk: '>=2.17.0 <3.0.0'
dependencies:
meta: ^1.0.2
diff --git a/pkg/_fe_analyzer_shared/test/macros/util.dart b/pkg/_fe_analyzer_shared/test/macros/util.dart
index fea0464..3e68eb6 100644
--- a/pkg/_fe_analyzer_shared/test/macros/util.dart
+++ b/pkg/_fe_analyzer_shared/test/macros/util.dart
@@ -114,17 +114,13 @@
final ResolvedIdentifier resolved;
TestIdentifier({
- required int id,
- required String name,
+ required super.id,
+ required super.name,
required IdentifierKind kind,
required Uri uri,
required String? staticScope,
- }) : resolved = ResolvedIdentifier(
- kind: kind, name: name, staticScope: staticScope, uri: uri),
- super(
- id: id,
- name: name,
- );
+ }) : resolved = ResolvedIdentifier(
+ kind: kind, name: name, staticScope: staticScope, uri: uri);
}
extension DebugCodeString on Code {
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index ed113f0..f49952a 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -1,4 +1,4 @@
-## 4.2.0-dev
+## 4.2.0
* Update SDK constraints to `>=2.17.0 <3.0.0`.
* Deprecated `ImportDirective.COMPARATOR`, use appropriate custom logic, if necessary.
* Deprecated `Element.isAccessibleIn()`, use `isAccessibleIn2()` instead.
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
index 1164841..ffd31fe 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
@@ -551,19 +551,8 @@
!_equalByteLists(_apiSignature, newApiSignature);
_apiSignature = newApiSignature;
- // The API signature changed.
- // Flush affected library cycles.
- // Flush exported top-level declarations of all files.
- if (apiSignatureChanged) {
- // TODO(scheglov) Make it a method of FileStateKind?
- final kind = _kind;
- if (kind is LibraryFileStateKind) {
- kind._libraryCycle?.invalidate();
- }
- _invalidatesLibrariesOfThisPart();
- }
-
// It is possible that this file does not reference these files.
+ // TODO(scheglov) This also could be moved, almost.
_stopReferencingByThisFile();
// Read imports/exports on demand.
@@ -662,27 +651,6 @@
}
}
- /// If this is a part, invalidate the libraries that use it.
- /// TODO(scheglov) Make it a method of `PartFileStateKind`?
- void _invalidatesLibrariesOfThisPart() {
- if (_kind is PartFileStateKind) {
- final libraries = _fsState._pathToFile.values
- .map((file) => file._kind)
- .whereType<LibraryFileStateKind>()
- .toList();
-
- for (final library in libraries) {
- for (final partDirective in library.parts) {
- if (partDirective is PartDirectiveWithFile) {
- if (partDirective.includedFile == this) {
- library._libraryCycle?.invalidate();
- }
- }
- }
- }
- }
- }
-
CompilationUnitImpl _parse(AnalysisErrorListener errorListener) {
return parse2(errorListener, content);
}
@@ -778,11 +746,10 @@
);
}
} else if (libraryDirective != null) {
- final kind = _kind = LibraryFileStateKind(
+ _kind = LibraryFileStateKind(
file: this,
name: libraryDirective.name,
);
- _fsState._libraryNameToFiles.add(kind);
} else if (partOfNameDirective != null) {
_kind = PartOfNameFileStateKind(
file: this,
@@ -812,8 +779,6 @@
name: null,
);
}
-
- _invalidatesLibrariesOfThisPart();
}
static UnlinkedUnit serializeAstUnlinked2(
@@ -1618,7 +1583,9 @@
LibraryFileStateKind({
required super.file,
required this.name,
- });
+ }) {
+ file._fsState._libraryNameToFiles.add(this);
+ }
/// The list of files files that this library consists of, i.e. this library
/// file itself, its [parts], and augmentations.
@@ -1925,10 +1892,29 @@
abstract class PartFileStateKind extends FileStateKind {
PartFileStateKind({
required super.file,
- });
+ }) {
+ _invalidateLibraries();
+ }
+
+ @override
+ void dispose() {
+ _invalidateLibraries();
+ super.dispose();
+ }
/// Returns `true` if the `part of` directive confirms the [library].
bool isPartOf(LibraryFileStateKind library);
+
+ /// This method is invoked when the part file is updated.
+ /// The file either becomes a part, or might stop being a part.
+ void _invalidateLibraries() {
+ for (final reference in file.referencingFiles) {
+ final referenceKind = reference.kind;
+ if (referenceKind is LibraryFileStateKind) {
+ referenceKind.invalidateLibraryCycle();
+ }
+ }
+ }
}
/// The file has `part of name` directive.
diff --git a/pkg/analyzer/pubspec.yaml b/pkg/analyzer/pubspec.yaml
index 77c258e..da576fd 100644
--- a/pkg/analyzer/pubspec.yaml
+++ b/pkg/analyzer/pubspec.yaml
@@ -1,5 +1,5 @@
name: analyzer
-version: 4.2.0-dev
+version: 4.2.0
description: This package provides a library that performs static analysis of Dart code.
repository: https://github.com/dart-lang/sdk/tree/main/pkg/analyzer
@@ -7,7 +7,7 @@
sdk: '>=2.17.0 <3.0.0'
dependencies:
- _fe_analyzer_shared: ^40.0.0
+ _fe_analyzer_shared: ^41.0.0
collection: ^1.15.0
convert: ^3.0.0
crypto: ^3.0.0
diff --git a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
index 5ac5829..ef21d7a 100644
--- a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
@@ -4141,7 +4141,7 @@
library_2 dart:core synthetic
augmentations
notAugmentation file_1
- cycle_0
+ cycle_2
dependencies: dart:core
libraries: library_0
apiSignature_0
@@ -4173,7 +4173,7 @@
library_2 dart:core synthetic
augmentations
notAugmentation file_1
- cycle_2
+ cycle_3
dependencies: dart:core
libraries: library_8
apiSignature_0
@@ -4211,7 +4211,7 @@
library_2 dart:core synthetic
parts
partOfName_7
- cycle_3
+ cycle_4
dependencies: dart:core
libraries: library_9
apiSignature_1
@@ -4291,7 +4291,7 @@
library_2 dart:core synthetic
augmentations
notAugmentation file_1
- cycle_0
+ cycle_2
dependencies: dart:core
libraries: library_0
apiSignature_0
@@ -4321,7 +4321,7 @@
library_2 dart:core synthetic
augmentations
notAugmentation file_1
- cycle_2
+ cycle_3
dependencies: dart:core
libraries: library_8
apiSignature_0
@@ -4356,7 +4356,7 @@
library_2 dart:core synthetic
parts
partOfUriKnown_7
- cycle_3
+ cycle_4
dependencies: dart:core
libraries: library_9
apiSignature_1
@@ -4975,7 +4975,6 @@
// `a.dart` is still a part.
// ...but the unlinked signature of `a.dart` is different.
// API signatures of both `b.dart` and `c.dart` changed.
- // Even though `a.dart` is not a valid part of `c.dart`.
assertDriverStateString(testFile, r'''
files
/home/test/lib/a.dart
diff --git a/pkg/compiler/test/dump_info/data_new/marker.options b/pkg/compiler/test/dump_info/data_new/marker.options
new file mode 100644
index 0000000..b9803ce
--- /dev/null
+++ b/pkg/compiler/test/dump_info/data_new/marker.options
@@ -0,0 +1,2 @@
+spec=pkg/compiler/test/dump_info/dump_info_new_test.dart
+
diff --git a/pkg/compiler/test/dump_info/data_new/mixin_with_tearoff_test.dart b/pkg/compiler/test/dump_info/data_new/mixin_with_tearoff_test.dart
new file mode 100644
index 0000000..b9fea3b
--- /dev/null
+++ b/pkg/compiler/test/dump_info/data_new/mixin_with_tearoff_test.dart
@@ -0,0 +1,400 @@
+//@dart = 2.9
+
+/*library:
+ constant=[
+ {
+ "id": "constant/B.C_JS_CONST = function getTagFallback(o) {\n var s = Object.prototype.toString.call(o);\n return s.substring(8, s.length - 1);\n};\n",
+ "kind": "constant",
+ "name": "",
+ "size": 131,
+ "outputUnit": "outputUnit/main",
+ "code": "B.C_JS_CONST = function getTagFallback(o) {\n var s = Object.prototype.toString.call(o);\n return s.substring(8, s.length - 1);\n};\n"
+},
+ {
+ "id": "constant/B.Interceptor_methods = J.Interceptor.prototype;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 49,
+ "outputUnit": "outputUnit/main",
+ "code": "B.Interceptor_methods = J.Interceptor.prototype;\n"
+},
+ {
+ "id": "constant/B.JSArray_methods = J.JSArray.prototype;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 41,
+ "outputUnit": "outputUnit/main",
+ "code": "B.JSArray_methods = J.JSArray.prototype;\n"
+},
+ {
+ "id": "constant/B.JSInt_methods = J.JSInt.prototype;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 37,
+ "outputUnit": "outputUnit/main",
+ "code": "B.JSInt_methods = J.JSInt.prototype;\n"
+},
+ {
+ "id": "constant/B.JSString_methods = J.JSString.prototype;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 43,
+ "outputUnit": "outputUnit/main",
+ "code": "B.JSString_methods = J.JSString.prototype;\n"
+},
+ {
+ "id": "constant/B.JavaScriptObject_methods = J.JavaScriptObject.prototype;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 59,
+ "outputUnit": "outputUnit/main",
+ "code": "B.JavaScriptObject_methods = J.JavaScriptObject.prototype;\n"
+},
+ {
+ "id": "constant/B.Type_Object_xQ6 = A.typeLiteral(\"Object\");\n",
+ "kind": "constant",
+ "name": "",
+ "size": 45,
+ "outputUnit": "outputUnit/main",
+ "code": "B.Type_Object_xQ6 = A.typeLiteral(\"Object\");\n"
+},
+ {
+ "id": "constant/B.Type_dynamic_0Rz = A.typeLiteral(\"@\");\n",
+ "kind": "constant",
+ "name": "",
+ "size": 41,
+ "outputUnit": "outputUnit/main",
+ "code": "B.Type_dynamic_0Rz = A.typeLiteral(\"@\");\n"
+}],
+ deferredFiles=[{}],
+ dependencies=[{}],
+ library=[{
+ "id": "library/memory:sdk/tests/web/native/main.dart::",
+ "kind": "library",
+ "name": "memory:sdk/tests/web/native/main.dart",
+ "size": 842,
+ "children": [
+ "class/memory:sdk/tests/web/native/main.dart::Clazz",
+ "class/memory:sdk/tests/web/native/main.dart::Mixin",
+ "class/memory:sdk/tests/web/native/main.dart::Subclass",
+ "class/memory:sdk/tests/web/native/main.dart::Super",
+ "function/memory:sdk/tests/web/native/main.dart::main"
+ ],
+ "canonicalUri": "memory:sdk/tests/web/native/main.dart"
+}],
+ outputUnits=[{
+ "id": "outputUnit/main",
+ "kind": "outputUnit",
+ "name": "main",
+ "filename": "out",
+ "imports": []
+}]
+*/
+
+import 'package:expect/expect.dart';
+
+/*class: Super:class=[{
+ "id": "class/memory:sdk/tests/web/native/main.dart::Super",
+ "kind": "class",
+ "name": "Super",
+ "size": 62,
+ "outputUnit": "outputUnit/main",
+ "parent": "library/memory:sdk/tests/web/native/main.dart::",
+ "modifiers": {
+ "abstract": false
+ },
+ "children": []
+}]*/
+class Super<T> {
+ void method(T t) {}
+}
+
+/*class: Mixin:class=[{
+ "id": "class/memory:sdk/tests/web/native/main.dart::Mixin",
+ "kind": "class",
+ "name": "Mixin",
+ "size": 89,
+ "outputUnit": "outputUnit/main",
+ "parent": "library/memory:sdk/tests/web/native/main.dart::",
+ "modifiers": {
+ "abstract": false
+ },
+ "children": [
+ "function/memory:sdk/tests/web/native/main.dart::Mixin.method"
+ ]
+}]*/
+class Mixin {
+ /*member: Mixin.method:
+ function=[{
+ "id": "function/memory:sdk/tests/web/native/main.dart::Mixin.method",
+ "kind": "function",
+ "name": "method",
+ "size": 81,
+ "outputUnit": "outputUnit/main",
+ "parent": "class/memory:sdk/tests/web/native/main.dart::Mixin",
+ "children": [],
+ "modifiers": {
+ "static": false,
+ "const": false,
+ "factory": false,
+ "external": false
+ },
+ "returnType": "void",
+ "inferredReturnType": "[null]",
+ "parameters": [
+ {
+ "name": "t",
+ "type": "[exact=JSUInt31]",
+ "declaredType": "int*"
+ }
+ ],
+ "sideEffects": "SideEffects(reads nothing; writes nothing)",
+ "inlinedCount": 0,
+ "code": "method$1(t) {\n }\nvar _ = A.Mixin.prototype;\n\n_.super$Mixin$method = _.method$1;\n",
+ "type": "void Function(int*)*",
+ "functionKind": 2
+}],
+ holding=[
+ {"id":"function/dart:_rti::Rti._bind","mask":null},
+ {"id":"function/dart:_rti::Rti._eval","mask":null},
+ {"id":"function/dart:_rti::_arrayInstanceType","mask":null},
+ {"id":"function/dart:_rti::_asBool","mask":null},
+ {"id":"function/dart:_rti::_asBoolQ","mask":null},
+ {"id":"function/dart:_rti::_asBoolS","mask":null},
+ {"id":"function/dart:_rti::_asDouble","mask":null},
+ {"id":"function/dart:_rti::_asDoubleQ","mask":null},
+ {"id":"function/dart:_rti::_asDoubleS","mask":null},
+ {"id":"function/dart:_rti::_asInt","mask":null},
+ {"id":"function/dart:_rti::_asIntQ","mask":null},
+ {"id":"function/dart:_rti::_asIntS","mask":null},
+ {"id":"function/dart:_rti::_asNum","mask":null},
+ {"id":"function/dart:_rti::_asNumQ","mask":null},
+ {"id":"function/dart:_rti::_asNumS","mask":null},
+ {"id":"function/dart:_rti::_asObject","mask":null},
+ {"id":"function/dart:_rti::_asString","mask":null},
+ {"id":"function/dart:_rti::_asStringQ","mask":null},
+ {"id":"function/dart:_rti::_asStringS","mask":null},
+ {"id":"function/dart:_rti::_asTop","mask":null},
+ {"id":"function/dart:_rti::_generalAsCheckImplementation","mask":null},
+ {"id":"function/dart:_rti::_generalIsTestImplementation","mask":null},
+ {"id":"function/dart:_rti::_generalNullableAsCheckImplementation","mask":null},
+ {"id":"function/dart:_rti::_generalNullableIsTestImplementation","mask":null},
+ {"id":"function/dart:_rti::_installSpecializedAsCheck","mask":null},
+ {"id":"function/dart:_rti::_installSpecializedIsTest","mask":null},
+ {"id":"function/dart:_rti::_instanceType","mask":null},
+ {"id":"function/dart:_rti::_isBool","mask":null},
+ {"id":"function/dart:_rti::_isInt","mask":null},
+ {"id":"function/dart:_rti::_isNum","mask":null},
+ {"id":"function/dart:_rti::_isObject","mask":null},
+ {"id":"function/dart:_rti::_isString","mask":null},
+ {"id":"function/dart:_rti::_isTop","mask":null},
+ {"id":"function/dart:_rti::findType","mask":null},
+ {"id":"function/dart:_rti::instanceType","mask":null}]
+ */
+ void method(int t) {}
+}
+
+/*class: Clazz:class=[{
+ "id": "class/memory:sdk/tests/web/native/main.dart::Clazz",
+ "kind": "class",
+ "name": "Clazz",
+ "size": 192,
+ "outputUnit": "outputUnit/main",
+ "parent": "library/memory:sdk/tests/web/native/main.dart::",
+ "modifiers": {
+ "abstract": false
+ },
+ "children": [
+ "function/memory:sdk/tests/web/native/main.dart::Clazz.method"
+ ]
+}]*/
+/*member: Clazz.method:
+ function=[{
+ "id": "function/memory:sdk/tests/web/native/main.dart::Clazz.method",
+ "kind": "function",
+ "name": "method",
+ "size": 162,
+ "outputUnit": "outputUnit/main",
+ "parent": "class/memory:sdk/tests/web/native/main.dart::Clazz",
+ "children": [],
+ "modifiers": {
+ "static": false,
+ "const": false,
+ "factory": false,
+ "external": false
+ },
+ "returnType": "void",
+ "inferredReturnType": "[null]",
+ "parameters": [
+ {
+ "name": "t",
+ "type": "Union([exact=JSString], [exact=JSUInt31])",
+ "declaredType": "int*"
+ }
+ ],
+ "sideEffects": "SideEffects(reads nothing; writes nothing)",
+ "inlinedCount": 1,
+ "code": "method$1(t) {\n return this.super$Mixin$method(A._asIntS(t));\n }\n_instance(A.Clazz.prototype, \"get$method\", 0, 1, null, [\"call$1\"], [\"method$1\"], 0, 0, 1);\n",
+ "type": "void Function(int*)*",
+ "functionKind": 2
+}],
+ holding=[
+ {"id":"function/dart:_rti::Rti._bind","mask":null},
+ {"id":"function/dart:_rti::Rti._eval","mask":null},
+ {"id":"function/dart:_rti::_arrayInstanceType","mask":null},
+ {"id":"function/dart:_rti::_asBool","mask":null},
+ {"id":"function/dart:_rti::_asBoolQ","mask":null},
+ {"id":"function/dart:_rti::_asBoolS","mask":null},
+ {"id":"function/dart:_rti::_asDouble","mask":null},
+ {"id":"function/dart:_rti::_asDoubleQ","mask":null},
+ {"id":"function/dart:_rti::_asDoubleS","mask":null},
+ {"id":"function/dart:_rti::_asInt","mask":null},
+ {"id":"function/dart:_rti::_asIntQ","mask":null},
+ {"id":"function/dart:_rti::_asIntS","mask":null},
+ {"id":"function/dart:_rti::_asNum","mask":null},
+ {"id":"function/dart:_rti::_asNumQ","mask":null},
+ {"id":"function/dart:_rti::_asNumS","mask":null},
+ {"id":"function/dart:_rti::_asObject","mask":null},
+ {"id":"function/dart:_rti::_asString","mask":null},
+ {"id":"function/dart:_rti::_asStringQ","mask":null},
+ {"id":"function/dart:_rti::_asStringS","mask":null},
+ {"id":"function/dart:_rti::_asTop","mask":null},
+ {"id":"function/dart:_rti::_generalAsCheckImplementation","mask":null},
+ {"id":"function/dart:_rti::_generalIsTestImplementation","mask":null},
+ {"id":"function/dart:_rti::_generalNullableAsCheckImplementation","mask":null},
+ {"id":"function/dart:_rti::_generalNullableIsTestImplementation","mask":null},
+ {"id":"function/dart:_rti::_installSpecializedAsCheck","mask":null},
+ {"id":"function/dart:_rti::_installSpecializedIsTest","mask":null},
+ {"id":"function/dart:_rti::_instanceType","mask":null},
+ {"id":"function/dart:_rti::_isBool","mask":null},
+ {"id":"function/dart:_rti::_isInt","mask":null},
+ {"id":"function/dart:_rti::_isNum","mask":null},
+ {"id":"function/dart:_rti::_isObject","mask":null},
+ {"id":"function/dart:_rti::_isString","mask":null},
+ {"id":"function/dart:_rti::_isTop","mask":null},
+ {"id":"function/dart:_rti::findType","mask":null},
+ {"id":"function/dart:_rti::instanceType","mask":null},
+ {"id":"function/memory:sdk/tests/web/native/main.dart::Mixin.method","mask":null}]
+*/
+class Clazz = Super<int> with Mixin;
+
+/*class: Subclass:class=[{
+ "id": "class/memory:sdk/tests/web/native/main.dart::Subclass",
+ "kind": "class",
+ "name": "Subclass",
+ "size": 95,
+ "outputUnit": "outputUnit/main",
+ "parent": "library/memory:sdk/tests/web/native/main.dart::",
+ "modifiers": {
+ "abstract": false
+ },
+ "children": [
+ "function/memory:sdk/tests/web/native/main.dart::Subclass.Subclass",
+ "function/memory:sdk/tests/web/native/main.dart::Subclass.test"
+ ]
+}]*/
+/*member: Subclass.:function=[{
+ "id": "function/memory:sdk/tests/web/native/main.dart::Subclass.Subclass",
+ "kind": "function",
+ "name": "Subclass",
+ "size": 0,
+ "outputUnit": "outputUnit/main",
+ "parent": "class/memory:sdk/tests/web/native/main.dart::Subclass",
+ "children": [],
+ "modifiers": {
+ "static": false,
+ "const": false,
+ "factory": false,
+ "external": false
+ },
+ "returnType": "Subclass*",
+ "inferredReturnType": "[exact=Subclass]",
+ "parameters": [],
+ "sideEffects": "SideEffects(reads nothing; writes nothing)",
+ "inlinedCount": 1,
+ "code": "",
+ "type": "Subclass* Function()*",
+ "functionKind": 3
+}]*/
+class Subclass extends Clazz {
+ /*member: Subclass.test:function=[{
+ "id": "function/memory:sdk/tests/web/native/main.dart::Subclass.test",
+ "kind": "function",
+ "name": "test",
+ "size": 0,
+ "outputUnit": "outputUnit/main",
+ "parent": "class/memory:sdk/tests/web/native/main.dart::Subclass",
+ "children": [],
+ "modifiers": {
+ "static": false,
+ "const": false,
+ "factory": false,
+ "external": false
+ },
+ "returnType": "void",
+ "inferredReturnType": "[null]",
+ "parameters": [],
+ "sideEffects": "SideEffects(reads anything; writes anything)",
+ "inlinedCount": 1,
+ "code": "",
+ "type": "void Function()*",
+ "functionKind": 2
+}]*/
+ void test() {
+ void Function(int) f = super.method;
+ f(0);
+ }
+}
+
+/*member: main:
+ closure=[{
+ "id": "closure/memory:sdk/tests/web/native/main.dart::main.main_closure",
+ "kind": "closure",
+ "name": "main_closure",
+ "size": 237,
+ "outputUnit": "outputUnit/main",
+ "parent": "function/memory:sdk/tests/web/native/main.dart::main",
+ "function": "function/memory:sdk/tests/web/native/main.dart::main.main_closure.call"
+}],
+ function=[{
+ "id": "function/memory:sdk/tests/web/native/main.dart::main",
+ "kind": "function",
+ "name": "main",
+ "size": 404,
+ "outputUnit": "outputUnit/main",
+ "parent": "library/memory:sdk/tests/web/native/main.dart::",
+ "children": [
+ "closure/memory:sdk/tests/web/native/main.dart::main.main_closure"
+ ],
+ "modifiers": {
+ "static": false,
+ "const": false,
+ "factory": false,
+ "external": false
+ },
+ "returnType": "dynamic",
+ "inferredReturnType": "[null]",
+ "parameters": [],
+ "sideEffects": "SideEffects(reads anything; writes anything)",
+ "inlinedCount": 0,
+ "code": "main() {\n var s = new A.Subclass();\n A.Clazz.prototype.get$method.call(s).call$1(0);\n A.Expect_throws(new A.main_closure(s), type$.legacy_Object);\n }",
+ "type": "dynamic Function()*",
+ "functionKind": 0
+}],
+ holding=[
+ {"id":"function/dart:_js_helper::closureFromTearOff","mask":null},
+ {"id":"function/dart:_rti::_setArrayType","mask":null},
+ {"id":"function/dart:_rti::findType","mask":null},
+ {"id":"function/memory:sdk/tests/web/native/main.dart::Clazz.method","mask":null},
+ {"id":"function/memory:sdk/tests/web/native/main.dart::Subclass.Subclass","mask":"inlined"},
+ {"id":"function/memory:sdk/tests/web/native/main.dart::Subclass.Subclass","mask":null},
+ {"id":"function/memory:sdk/tests/web/native/main.dart::Subclass.test","mask":"inlined"},
+ {"id":"function/memory:sdk/tests/web/native/main.dart::Subclass.test","mask":null},
+ {"id":"function/memory:sdk/tests/web/native/main.dart::main.main_closure.call","mask":null},
+ {"id":"function/memory:sdk/tests/web/native/main.dart::main.main_closure.call","mask":null},
+ {"id":"function/package:expect/expect.dart::Expect.throws","mask":null}]
+*/
+main() {
+ Super<Object> s = new Subclass()..test();
+ Expect.throws(() => s.method(''));
+}
diff --git a/pkg/compiler/test/dump_info/dump_info_new_regression_test.dart b/pkg/compiler/test/dump_info/dump_info_new_regression_test.dart
index 42c10b3..baae6e9 100644
--- a/pkg/compiler/test/dump_info/dump_info_new_regression_test.dart
+++ b/pkg/compiler/test/dump_info/dump_info_new_regression_test.dart
@@ -26,10 +26,10 @@
final JsonEncoder indentedEncoder = const JsonEncoder.withIndent(' ');
String jsonEncode(Map object, {bool indent = true}) {
- var jsonEncoder = indent ? indentedEncoder : encoder;
- var transformedObject = transformJsonObjectForComparison(object);
+ final jsonEncoder = indent ? indentedEncoder : encoder;
+ final transformedObject = transformJsonObjectForComparison(object);
// Filter block comments since they interfere with ID test comments.
- var json = jsonEncoder
+ final json = jsonEncoder
.convert(transformedObject)
.replaceAll('/*', '')
.replaceAll('*/', '');
@@ -54,7 +54,7 @@
}
// Ignore sizes for output units, as these deviate by some constant when
- // `--canary` is enabled.
+ // `--new-dump-info` is enabled.
if (object['kind'] == 'outputUnit' && key == 'size') {
return;
}
@@ -89,12 +89,12 @@
asyncTest(() async {
Directory dataDir = Directory.fromUri(Platform.script.resolve('data'));
- print('Testing output of dump-info');
+ print('Testing output of new-dump-info');
print('==================================================================');
await checkTests(dataDir, const DumpInfoDataComputer(),
args: filteredArgs,
testedConfigs: allSpecConfigs,
- options: ['--dump-info', '--canary', '--enable-asserts']);
+ options: ['--dump-info', '--new-dump-info', '--enable-asserts']);
});
}
diff --git a/pkg/compiler/test/dump_info/dump_info_new_test.dart b/pkg/compiler/test/dump_info/dump_info_new_test.dart
new file mode 100644
index 0000000..97c9595
--- /dev/null
+++ b/pkg/compiler/test/dump_info/dump_info_new_test.dart
@@ -0,0 +1,302 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// @dart = 2.7
+
+import 'dart:convert';
+import 'dart:io';
+import 'package:_fe_analyzer_shared/src/testing/features.dart';
+import 'package:async_helper/async_helper.dart';
+import 'package:compiler/src/compiler.dart';
+import 'package:compiler/src/dump_info.dart';
+import 'package:compiler/src/elements/entities.dart';
+import 'package:compiler/src/js_model/element_map.dart';
+import 'package:compiler/src/js_model/js_world.dart';
+import 'package:dart2js_info/info.dart' as info;
+import 'package:dart2js_info/json_info_codec.dart' as info;
+import 'package:kernel/ast.dart' as ir;
+import '../equivalence/id_equivalence.dart';
+import '../equivalence/id_equivalence_helper.dart';
+
+final JsonEncoder encoder = const JsonEncoder();
+final JsonEncoder indentedEncoder = const JsonEncoder.withIndent(' ');
+
+String jsonEncode(Map object, {bool indent = true}) {
+ final jsonEncoder = indent ? indentedEncoder : encoder;
+ // Filter block comments since they interfere with ID test comments.
+ final json =
+ jsonEncoder.convert(object).replaceAll('/*', '').replaceAll('*/', '');
+ return json;
+}
+
+Map filteredJsonObject(Map object, Set<String> filteredFields) {
+ Map filteredObject = {};
+ object.forEach((key, value) {
+ if (filteredFields.contains(key)) return;
+ filteredObject[key] = value;
+ });
+ return filteredObject;
+}
+
+main(List<String> args) {
+ asyncTest(() async {
+ Directory dataDir = Directory.fromUri(Platform.script.resolve('data_new'));
+ print('Testing output of new-dump-info');
+ print('==================================================================');
+ await checkTests(dataDir, const DumpInfoDataComputer(),
+ args: args,
+ testedConfigs: allSpecConfigs,
+ options: ['--dump-info', '--new-dump-info', '--enable-asserts']);
+ });
+}
+
+class Tags {
+ static const String library = 'library';
+ static const String clazz = 'class';
+ static const String classType = 'classType';
+ static const String closure = 'closure';
+ static const String function = 'function';
+ static const String typeDef = 'typedef';
+ static const String field = 'field';
+ static const String constant = 'constant';
+ static const String holding = 'holding';
+ static const String dependencies = 'dependencies';
+ static const String outputUnits = 'outputUnits';
+ static const String deferredFiles = 'deferredFiles';
+}
+
+class DumpInfoDataComputer extends DataComputer<Features> {
+ const DumpInfoDataComputer();
+
+ static const String wildcard = '%';
+
+ @override
+ void computeLibraryData(Compiler compiler, LibraryEntity library,
+ Map<Id, ActualData<Features>> actualMap,
+ {bool verbose}) {
+ final converter = info.AllInfoToJsonConverter(isBackwardCompatible: true);
+ DumpInfoStateData dumpInfoState = compiler.dumpInfoStateForTesting;
+
+ final features = Features();
+ final libraryInfo = dumpInfoState.entityToInfo[library];
+ if (libraryInfo == null) return;
+
+ features.addElement(
+ Tags.library, jsonEncode(libraryInfo.accept(converter)));
+
+ // Store program-wide information on the main library.
+ final name = '${library.canonicalUri.pathSegments.last}';
+ if (name.startsWith('main')) {
+ for (final constantInfo in dumpInfoState.info.constants) {
+ features.addElement(
+ Tags.constant, jsonEncode(constantInfo.accept(converter)));
+ }
+ features.addElement(
+ Tags.dependencies, jsonEncode(dumpInfoState.info.dependencies));
+ for (final outputUnit in dumpInfoState.info.outputUnits) {
+ var outputUnitJsonObject = outputUnit.accept(converter);
+ // Remove the size from the main output unit due to high noise ratio.
+ if (outputUnit.name == 'main') {
+ outputUnitJsonObject =
+ filteredJsonObject(outputUnitJsonObject, {'size'});
+ }
+ features.addElement(Tags.outputUnits, jsonEncode(outputUnitJsonObject));
+ }
+ features.addElement(
+ Tags.deferredFiles, jsonEncode(dumpInfoState.info.deferredFiles));
+ }
+
+ final id = LibraryId(library.canonicalUri);
+ actualMap[id] =
+ ActualData<Features>(id, features, library.canonicalUri, -1, library);
+ }
+
+ @override
+ void computeClassData(Compiler compiler, ClassEntity cls,
+ Map<Id, ActualData<Features>> actualMap,
+ {bool verbose: false}) {
+ final converter = info.AllInfoToJsonConverter(isBackwardCompatible: true);
+ DumpInfoStateData dumpInfoState = compiler.dumpInfoStateForTesting;
+
+ final features = Features();
+ final classInfo = dumpInfoState.entityToInfo[cls];
+ if (classInfo == null) return;
+
+ features.addElement(Tags.clazz, jsonEncode(classInfo.accept(converter)));
+ final classTypeInfos =
+ dumpInfoState.info.classTypes.where((i) => i.name == classInfo.name);
+ assert(
+ classTypeInfos.length < 2,
+ 'Ambiguous class type info resolution. '
+ 'Expected 0 or 1 elements, found: $classTypeInfos');
+ if (classTypeInfos.length == 1) {
+ features.addElement(
+ Tags.classType, jsonEncode(classTypeInfos.first.accept(converter)));
+ }
+
+ JsClosedWorld closedWorld = compiler.backendClosedWorldForTesting;
+ JsToElementMap elementMap = closedWorld.elementMap;
+ ir.Class node = elementMap.getClassDefinition(cls).node;
+ ClassId id = ClassId(node.name);
+ ir.TreeNode nodeWithOffset = computeTreeNodeWithOffset(node);
+ actualMap[id] = ActualData<Features>(id, features,
+ nodeWithOffset?.location?.file, nodeWithOffset?.fileOffset, cls);
+ }
+
+ @override
+ void computeMemberData(Compiler compiler, MemberEntity member,
+ Map<Id, ActualData<Features>> actualMap,
+ {bool verbose: false}) {
+ final converter = info.AllInfoToJsonConverter(isBackwardCompatible: true);
+ DumpInfoStateData dumpInfoState = compiler.dumpInfoStateForTesting;
+
+ final features = Features();
+ final functionInfo = dumpInfoState.entityToInfo[member];
+ if (functionInfo == null) return;
+
+ if (functionInfo is info.FunctionInfo) {
+ features.addElement(
+ Tags.function, jsonEncode(functionInfo.accept(converter)));
+ for (final use in functionInfo.uses) {
+ features.addElement(Tags.holding,
+ jsonEncode(converter.visitDependencyInfo(use), indent: false));
+ }
+ for (final closure in functionInfo.closures) {
+ features.addElement(
+ Tags.closure, jsonEncode(closure.accept(converter)));
+ }
+ }
+
+ if (functionInfo is info.FieldInfo) {
+ features.addElement(
+ Tags.function, jsonEncode(functionInfo.accept(converter)));
+ for (final use in functionInfo.uses) {
+ features.addElement(Tags.holding,
+ jsonEncode(converter.visitDependencyInfo(use), indent: false));
+ }
+ for (final closure in functionInfo.closures) {
+ features.addElement(
+ Tags.closure, jsonEncode(closure.accept(converter)));
+ }
+ }
+
+ JsClosedWorld closedWorld = compiler.backendClosedWorldForTesting;
+ JsToElementMap elementMap = closedWorld.elementMap;
+ ir.Member node = elementMap.getMemberDefinition(member).node;
+ Id id = computeMemberId(node);
+ ir.TreeNode nodeWithOffset = computeTreeNodeWithOffset(node);
+ actualMap[id] = ActualData<Features>(id, features,
+ nodeWithOffset?.location?.file, nodeWithOffset?.fileOffset, member);
+ }
+
+ @override
+ DataInterpreter<Features> get dataValidator =>
+ const JsonFeaturesDataInterpreter(wildcard: wildcard);
+}
+
+/// Feature interpreter for Features with Json values.
+///
+/// The data annotation reader conserves whitespace visually while ignoring
+/// them during comparison.
+class JsonFeaturesDataInterpreter implements DataInterpreter<Features> {
+ final String wildcard;
+ final JsonEncoder encoder = const JsonEncoder();
+
+ const JsonFeaturesDataInterpreter({this.wildcard});
+
+ @override
+ String isAsExpected(Features actualFeatures, String expectedData) {
+ if (wildcard != null && expectedData == wildcard) {
+ return null;
+ } else if (expectedData == '') {
+ return actualFeatures.isNotEmpty ? "Expected empty data." : null;
+ } else {
+ List<String> errorsFound = [];
+ Features expectedFeatures = Features.fromText(expectedData);
+ Set<String> validatedFeatures = Set<String>();
+ expectedFeatures.forEach((String key, Object expectedValue) {
+ validatedFeatures.add(key);
+ Object actualValue = actualFeatures[key];
+ if (!actualFeatures.containsKey(key)) {
+ errorsFound.add('No data found for $key');
+ } else if (expectedValue == '') {
+ if (actualValue != '') {
+ errorsFound.add('Non-empty data found for $key');
+ }
+ } else if (wildcard != null && expectedValue == wildcard) {
+ return;
+ } else if (expectedValue is List) {
+ if (actualValue is List) {
+ List actualList = actualValue.toList();
+ for (Object expectedObject in expectedValue) {
+ String expectedText =
+ jsonEncode(jsonDecode(expectedObject), indent: false);
+ bool matchFound = false;
+ if (wildcard != null && expectedText.endsWith(wildcard)) {
+ // Wildcard matcher.
+ String prefix =
+ expectedText.substring(0, expectedText.indexOf(wildcard));
+ List matches = [];
+ for (Object actualObject in actualList) {
+ final formattedActualObject =
+ jsonEncode(jsonDecode(actualObject), indent: false);
+ if (formattedActualObject.startsWith(prefix)) {
+ matches.add(actualObject);
+ matchFound = true;
+ }
+ }
+ for (Object match in matches) {
+ actualList.remove(match);
+ }
+ } else {
+ for (Object actualObject in actualList) {
+ final formattedActualObject =
+ jsonEncode(jsonDecode(actualObject), indent: false);
+ if (expectedText == formattedActualObject) {
+ actualList.remove(actualObject);
+ matchFound = true;
+ break;
+ }
+ }
+ }
+ if (!matchFound) {
+ errorsFound.add("No match found for $key=[$expectedText]");
+ }
+ }
+ if (actualList.isNotEmpty) {
+ errorsFound
+ .add("Extra data found $key=[${actualList.join(',')}]");
+ }
+ } else {
+ errorsFound.add("List data expected for $key: "
+ "expected '$expectedValue', found '${actualValue}'");
+ }
+ } else if (expectedValue != actualValue) {
+ errorsFound.add("Mismatch for $key: expected '$expectedValue', "
+ "found '${actualValue}'");
+ }
+ });
+ actualFeatures.forEach((String key, Object value) {
+ if (!validatedFeatures.contains(key)) {
+ if (value == '') {
+ errorsFound.add("Extra data found '$key'");
+ } else {
+ errorsFound.add("Extra data found $key=$value");
+ }
+ }
+ });
+ return errorsFound.isNotEmpty ? errorsFound.join('\n ') : null;
+ }
+ }
+
+ @override
+ String getText(Features actualData, [String indentation]) {
+ return actualData.getText(indentation);
+ }
+
+ @override
+ bool isEmpty(Features actualData) {
+ return actualData == null || actualData.isEmpty;
+ }
+}
diff --git a/pkg/compiler/test/dump_info/dump_info_test.dart b/pkg/compiler/test/dump_info/dump_info_test.dart
index 14b711e..1b3c017 100644
--- a/pkg/compiler/test/dump_info/dump_info_test.dart
+++ b/pkg/compiler/test/dump_info/dump_info_test.dart
@@ -23,9 +23,9 @@
final JsonEncoder indentedEncoder = const JsonEncoder.withIndent(' ');
String jsonEncode(Map object, {bool indent = true}) {
- var jsonEncoder = indent ? indentedEncoder : encoder;
+ final jsonEncoder = indent ? indentedEncoder : encoder;
// Filter block comments since they interfere with ID test comments.
- var json =
+ final json =
jsonEncoder.convert(object).replaceAll('/*', '').replaceAll('*/', '');
return json;
}
@@ -84,7 +84,7 @@
Tags.library, jsonEncode(libraryInfo.accept(converter)));
// Store program-wide information on the main library.
- var name = '${library.canonicalUri.pathSegments.last}';
+ final name = '${library.canonicalUri.pathSegments.last}';
if (name.startsWith('main')) {
for (final constantInfo in dumpInfoState.info.constants) {
features.addElement(
@@ -160,7 +160,7 @@
features.addElement(Tags.holding,
jsonEncode(converter.visitDependencyInfo(use), indent: false));
}
- for (var closure in functionInfo.closures) {
+ for (final closure in functionInfo.closures) {
features.addElement(
Tags.closure, jsonEncode(closure.accept(converter)));
}
@@ -173,7 +173,7 @@
features.addElement(Tags.holding,
jsonEncode(converter.visitDependencyInfo(use), indent: false));
}
- for (var closure in functionInfo.closures) {
+ for (final closure in functionInfo.closures) {
features.addElement(
Tags.closure, jsonEncode(closure.accept(converter)));
}
diff --git a/tools/VERSION b/tools/VERSION
index 4195349..702aecd 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 18
PATCH 0
-PRERELEASE 238
+PRERELEASE 239
PRERELEASE_PATCH 0
\ No newline at end of file