Version 2.17.0-14.0.dev
Merge commit 'b5d627cccb3a5d5d9a093803f56b4da32caf861f' into 'dev'
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 7c3972e..d7b4cbe 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -82,7 +82,7 @@
/// TODO(scheglov) Clean up the list of implicitly analyzed files.
class AnalysisDriver implements AnalysisDriverGeneric {
/// The version of data format, should be incremented on every format change.
- static const int DATA_VERSION = 197;
+ static const int DATA_VERSION = 199;
/// The number of exception contexts allowed to write. Once this field is
/// zero, we stop writing any new exception contexts in this process.
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 92517cf5..991fc7c 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -167,6 +167,20 @@
}
@override
+ ConstructorElement? getNamedConstructor(String name) {
+ if (name == 'new') {
+ // A constructor declared as `C.new` is unnamed, and is modeled as such.
+ name = '';
+ }
+ for (ConstructorElement element in constructors) {
+ if (element.name == name) {
+ return element;
+ }
+ }
+ return null;
+ }
+
+ @override
PropertyAccessorElement? getSetter(String setterName) {
return getSetterFromAccessors(setterName, accessors);
}
@@ -447,9 +461,6 @@
/// This callback is set during mixins inference to handle reentrant calls.
List<InterfaceType>? Function(ClassElementImpl)? mixinInferenceCallback;
- /// TODO(scheglov) implement as modifier
- bool _isSimplyBounded = true;
-
ElementLinkedData? linkedData;
/// Initialize a newly created class element to have the given [name] at the
@@ -661,15 +672,13 @@
setModifier(Modifier.MIXIN_APPLICATION, isMixinApplication);
}
- /// TODO(scheglov) implement as modifier
@override
bool get isSimplyBounded {
- return _isSimplyBounded;
+ return hasModifier(Modifier.SIMPLY_BOUNDED);
}
- /// TODO(scheglov) implement as modifier
set isSimplyBounded(bool isSimplyBounded) {
- _isSimplyBounded = isSimplyBounded;
+ setModifier(Modifier.SIMPLY_BOUNDED, isSimplyBounded);
}
@override
@@ -783,10 +792,6 @@
builder.writeClassElement(this);
}
- @override
- ConstructorElement? getNamedConstructor(String name) =>
- getNamedConstructorFromList(name, constructors);
-
void setLinkedData(Reference reference, ElementLinkedData linkedData) {
this.reference = reference;
reference.element = this;
@@ -948,20 +953,6 @@
return implicitConstructor;
}).toList(growable: false);
}
-
- static ConstructorElement? getNamedConstructorFromList(
- String name, List<ConstructorElement> constructors) {
- if (name == 'new') {
- // A constructor declared as `C.new` is unnamed, and is modeled as such.
- name = '';
- }
- for (ConstructorElement element in constructors) {
- if (element.name == name) {
- return element;
- }
- }
- return null;
- }
}
/// A concrete implementation of a [CompilationUnitElement].
@@ -2749,6 +2740,14 @@
return _methods;
}
+ /// Set the methods contained in this class to the given [methods].
+ set methods(List<MethodElement> methods) {
+ for (MethodElement method in methods) {
+ (method as MethodElementImpl).enclosingElement = this;
+ }
+ _methods = methods;
+ }
+
@override
List<InterfaceType> get mixins => const <InterfaceType>[];
@@ -2777,18 +2776,6 @@
builder.writeEnumElement(this);
}
- /// Create the only method enums have - `toString()`.
- void createToStringMethodElement() {
- var method = MethodElementImpl('toString', -1);
- method.isSynthetic = true;
- method.enclosingElement = this;
- method.reference = reference?.getChild('@method').getChild('toString');
- _methods = <MethodElement>[method];
- }
-
- @override
- ConstructorElement? getNamedConstructor(String name) => null;
-
void setLinkedData(Reference reference, ElementLinkedData linkedData) {
this.reference = reference;
reference.element = this;
@@ -4332,14 +4319,17 @@
/// Indicates that the pseudo-modifier 'set' was applied to the element.
static const Modifier SETTER = Modifier('SETTER', 19);
+ /// See [TypeParameterizedElement.isSimplyBounded].
+ static const Modifier SIMPLY_BOUNDED = Modifier('SIMPLY_BOUNDED', 20);
+
/// Indicates that the modifier 'static' was applied to the element.
- static const Modifier STATIC = Modifier('STATIC', 20);
+ static const Modifier STATIC = Modifier('STATIC', 21);
/// Indicates that the element does not appear in the source code but was
/// implicitly created. For example, if a class does not define any
/// constructors, an implicit zero-argument constructor will be created and it
/// will be marked as being synthetic.
- static const Modifier SYNTHETIC = Modifier('SYNTHETIC', 21);
+ static const Modifier SYNTHETIC = Modifier('SYNTHETIC', 22);
static const List<Modifier> values = [
ABSTRACT,
@@ -4362,6 +4352,7 @@
MIXIN_APPLICATION,
SETTER,
STATIC,
+ SIMPLY_BOUNDED,
SYNTHETIC
];
@@ -5445,10 +5436,6 @@
class TypeAliasElementImpl extends _ExistingElementImpl
with TypeParameterizedElementMixin
implements TypeAliasElement {
- /// TODO(scheglov) implement as modifier
- @override
- bool isSimplyBounded = true;
-
/// Is `true` if the element has direct or indirect reference to itself
/// from anywhere except a class element or type parameter bounds.
bool hasSelfReference = false;
@@ -5519,6 +5506,15 @@
}
@override
+ bool get isSimplyBounded {
+ return hasModifier(Modifier.SIMPLY_BOUNDED);
+ }
+
+ set isSimplyBounded(bool isSimplyBounded) {
+ setModifier(Modifier.SIMPLY_BOUNDED, isSimplyBounded);
+ }
+
+ @override
ElementKind get kind {
if (isNonFunctionTypeAliasesEnabled) {
return ElementKind.TYPE_ALIAS;
diff --git a/pkg/analyzer/lib/src/summary2/ast_resolver.dart b/pkg/analyzer/lib/src/summary2/ast_resolver.dart
index 411f10f..ead4620 100644
--- a/pkg/analyzer/lib/src/summary2/ast_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_resolver.dart
@@ -50,9 +50,13 @@
flowAnalysisHelper: _flowAnalysis,
);
- AstResolver(this._linker, this._unitElement, this._nameScope, AstNode node,
- {this.enclosingClassElement, this.enclosingExecutableElement})
- : _featureSet = node.thisOrAncestorOfType<CompilationUnit>()!.featureSet;
+ AstResolver(
+ this._linker,
+ this._unitElement,
+ this._nameScope, {
+ this.enclosingClassElement,
+ this.enclosingExecutableElement,
+ }) : _featureSet = _unitElement.library.featureSet;
void resolveAnnotation(AnnotationImpl node) {
node.accept(_resolutionVisitor);
diff --git a/pkg/analyzer/lib/src/summary2/bundle_reader.dart b/pkg/analyzer/lib/src/summary2/bundle_reader.dart
index 418f064..d567258 100644
--- a/pkg/analyzer/lib/src/summary2/bundle_reader.dart
+++ b/pkg/analyzer/lib/src/summary2/bundle_reader.dart
@@ -272,23 +272,10 @@
@override
void _read(element, reader) {
- var typeProvider = element.library.typeProvider;
-
element.metadata = reader._readAnnotationList(
unitElement: element.enclosingElement,
);
_readTypeParameters(reader, element.typeParameters);
-
- var indexField = element.getField('index') as FieldElementImpl;
- indexField.type = typeProvider.intType;
-
- var valuesField = element.getField('values') as ConstFieldElementImpl;
- valuesField.constantInitializer = reader._readRequiredNode() as Expression;
- valuesField.type = typeProvider.listType(element.thisType);
-
- var toStringMethod = element.getMethod('toString') as MethodElementImpl;
- toStringMethod.returnType = typeProvider.stringType;
-
applyConstantOffsets?.perform();
}
}
@@ -612,44 +599,14 @@
var accessors = <PropertyAccessorElement>[];
var fields = <FieldElement>[];
- // Build the 'index' field.
- {
- var indexField = ConstFieldElementImpl('index', -1)
- ..isFinal = true
- ..isSynthetic = true;
- indexField.bindReference(
- reference.getChild('@field').getChild('index'),
- );
- indexField.createImplicitAccessors(reference, 'index');
- fields.add(indexField);
- accessors.add(indexField.getter!);
- }
-
_readFields(unitElement, element, reference, accessors, fields);
_readPropertyAccessors(
unitElement, element, reference, accessors, fields, '@field');
-
- // Build the 'values' field.
- {
- var field = ConstFieldElementImpl('values', -1)
- ..isConst = true
- ..isStatic = true
- ..isSynthetic = true;
- fields.add(field);
- accessors.add(
- PropertyAccessorElementImpl_ImplicitGetter(field,
- reference: reference.getChild('@getter').getChild('values'))
- ..enclosingElement = element,
- );
- }
-
element.fields = fields;
element.accessors = accessors;
element.constructors = _readConstructors(unitElement, element, reference);
- // element.methods = _readMethods(unitElement, element, reference);
-
- element.createToStringMethodElement();
+ element.methods = _readMethods(unitElement, element, reference);
return element;
}
@@ -884,6 +841,7 @@
offset: resolutionOffset,
);
element.setLinkedData(reference, linkedData);
+ MixinElementFlags.read(_reader, element);
element.typeParameters = _readTypeParameters();
diff --git a/pkg/analyzer/lib/src/summary2/bundle_writer.dart b/pkg/analyzer/lib/src/summary2/bundle_writer.dart
index e27a303..c535cd7 100644
--- a/pkg/analyzer/lib/src/summary2/bundle_writer.dart
+++ b/pkg/analyzer/lib/src/summary2/bundle_writer.dart
@@ -175,11 +175,10 @@
_resolutionSink._writeAnnotationList(element.metadata);
_writeTypeParameters(element.typeParameters, () {
- var valuesField = element.getField('values') as ConstFieldElementImpl;
- _resolutionSink._writeNode(valuesField.constantInitializer!);
-
_writeList(
- element.fields.where((e) => !e.isSynthetic).toList(),
+ element.fields.where((e) {
+ return !e.isSynthetic || const {'index', 'values'}.contains(e.name);
+ }).toList(),
_writeFieldElement,
);
_writeList(
@@ -187,7 +186,7 @@
_writePropertyAccessorElement,
);
_writeList(element.constructors, _writeConstructorElement);
- // _writeList(element.methods, _writeMethodElement);
+ _writeList(element.methods, _writeMethodElement);
});
}
@@ -305,6 +304,7 @@
_sink.writeUInt30(_resolutionSink.offset);
_sink._writeStringReference(element.name);
+ MixinElementFlags.write(_sink, element);
_resolutionSink._writeAnnotationList(element.metadata);
_writeTypeParameters(element.typeParameters, () {
diff --git a/pkg/analyzer/lib/src/summary2/constructor_initializer_resolver.dart b/pkg/analyzer/lib/src/summary2/constructor_initializer_resolver.dart
index 48f2df7..0449c8c 100644
--- a/pkg/analyzer/lib/src/summary2/constructor_initializer_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/constructor_initializer_resolver.dart
@@ -46,7 +46,7 @@
element,
);
- var astResolver = AstResolver(_linker, unitElement, initializerScope, node,
+ var astResolver = AstResolver(_linker, unitElement, initializerScope,
enclosingClassElement: classElement,
enclosingExecutableElement: element);
diff --git a/pkg/analyzer/lib/src/summary2/default_value_resolver.dart b/pkg/analyzer/lib/src/summary2/default_value_resolver.dart
index 8518555..632a6c4 100644
--- a/pkg/analyzer/lib/src/summary2/default_value_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/default_value_resolver.dart
@@ -74,7 +74,6 @@
_linker,
context.unitElement,
context.scope,
- node.defaultValue!,
enclosingClassElement: context.classElement,
enclosingExecutableElement: context.executableElement,
);
diff --git a/pkg/analyzer/lib/src/summary2/element_builder.dart b/pkg/analyzer/lib/src/summary2/element_builder.dart
index 44a2eb3..9d9dadd 100644
--- a/pkg/analyzer/lib/src/summary2/element_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/element_builder.dart
@@ -223,6 +223,179 @@
}
});
+ var accessors = <PropertyAccessorElement>[];
+ var fields = <FieldElementImpl>[];
+ var methods = <MethodElement>[];
+
+ // Build the 'index' field.
+ ConstFieldElementImpl indexField;
+ {
+ indexField = ConstFieldElementImpl('index', -1)
+ ..isSynthetic = true
+ ..isFinal = true;
+ indexField.bindReference(
+ reference.getChild('@field').getChild('index'),
+ );
+ fields.add(indexField);
+ accessors.add(PropertyAccessorElementImpl_ImplicitGetter(indexField,
+ reference: reference.getChild('@getter').getChild('index')));
+ }
+
+ var constructorIndexParameter = FieldFormalParameterElementImpl(
+ name: 'index',
+ nameOffset: -1,
+ parameterKind: ParameterKind.REQUIRED,
+ )..field = indexField;
+
+ var constructorNameParameter = ParameterElementImpl(
+ name: 'name',
+ nameOffset: -1,
+ parameterKind: ParameterKind.REQUIRED,
+ );
+
+ var constructorName = '_';
+ if (node.constants.any((c) => c.name.name == '_')) {
+ constructorName = '_1';
+ }
+
+ var constructorReference =
+ reference.getChild('@constructor').getChild(constructorName);
+ var constructor = ConstructorElementImpl(constructorName, -1)
+ ..isConst = true
+ ..isSynthetic = true
+ ..parameters = [
+ constructorIndexParameter,
+ constructorNameParameter,
+ ]
+ ..reference = constructorReference;
+ constructorReference.element = constructor;
+ element.constructors = [constructor];
+
+ // Build fields for all enum constants.
+ var containerRef = reference.getChild('@field');
+ var constants = node.constants;
+ var valuesElements = <Expression>[];
+ for (var i = 0; i < constants.length; ++i) {
+ var constant = constants[i];
+ var name = constant.name.name;
+ var reference = containerRef.getChild(name);
+ var field = ConstFieldElementImpl(name, constant.name.offset)
+ ..hasImplicitType = true
+ ..isConst = true
+ ..isEnumConstant = true
+ ..isStatic = true
+ ..type = DynamicTypeImpl.instance;
+ _setCodeRange(field, constant);
+ _setDocumentation(field, constant);
+ field.reference = reference;
+ field.metadata = _buildAnnotationsWithUnit(
+ _unitElement,
+ constant.metadata,
+ );
+ var initializer = astFactory.instanceCreationExpression(
+ null,
+ astFactory.constructorName(
+ astFactory.namedType(
+ name: astFactory.simpleIdentifier(
+ StringToken(TokenType.STRING, element.name, -1),
+ ),
+ ),
+ Tokens.period(),
+ astFactory.simpleIdentifier(
+ StringToken(TokenType.STRING, constructorName, -1),
+ ),
+ ),
+ astFactory.argumentList(
+ Tokens.openParenthesis(),
+ [
+ astFactory.integerLiteral(
+ StringToken(TokenType.STRING, '$i', 0),
+ i,
+ ),
+ astFactory.simpleStringLiteral(
+ StringToken(TokenType.STRING, "'$name'", 0),
+ name,
+ ),
+ ],
+ Tokens.closeParenthesis(),
+ ),
+ );
+
+ var variableDeclaration = astFactory.variableDeclaration(
+ astFactory.simpleIdentifier(
+ StringToken(TokenType.STRING, name, -1),
+ ),
+ Tokens.eq(),
+ initializer,
+ );
+ astFactory.variableDeclarationList2(
+ variables: [variableDeclaration],
+ );
+ _linker.elementNodes[field] = variableDeclaration;
+
+ field.constantInitializer = initializer;
+ field.createImplicitAccessors(containerRef.parent!, name);
+ fields.add(field);
+ accessors.add(field.getter as PropertyAccessorElementImpl);
+ valuesElements.add(
+ astFactory.simpleIdentifier(
+ StringToken(TokenType.STRING, name, -1),
+ ),
+ );
+ }
+
+ // Build the 'values' field.
+ ConstFieldElementImpl valuesField;
+ NamedTypeImpl valuesTypeNode;
+ {
+ valuesField = ConstFieldElementImpl('values', -1)
+ ..isConst = true
+ ..isStatic = true
+ ..isSynthetic = true;
+ var initializer = astFactory.listLiteral(
+ null,
+ null,
+ Tokens.openSquareBracket(),
+ valuesElements,
+ Tokens.closeSquareBracket(),
+ );
+ valuesField.constantInitializer = initializer;
+
+ var variableDeclaration = astFactory.variableDeclaration(
+ astFactory.simpleIdentifier(
+ StringToken(TokenType.STRING, 'values', -1),
+ ),
+ Tokens.eq(),
+ initializer,
+ );
+ valuesTypeNode = astFactory.namedType(
+ name: astFactory.simpleIdentifier(
+ StringToken(TokenType.STRING, 'List', -1),
+ ),
+ typeArguments: astFactory.typeArgumentList(
+ Tokens.lt(),
+ [
+ astFactory.namedType(
+ name: astFactory.simpleIdentifier(
+ StringToken(TokenType.STRING, element.name, -1),
+ )..staticElement = element,
+ )
+ ],
+ Tokens.gt(),
+ ),
+ );
+ astFactory.variableDeclarationList2(
+ keyword: Tokens.const_(),
+ variables: [variableDeclaration],
+ type: valuesTypeNode,
+ );
+ _linker.elementNodes[valuesField] = variableDeclaration;
+
+ fields.add(valuesField);
+ accessors.add(PropertyAccessorElementImpl_ImplicitGetter(valuesField,
+ reference: reference.getChild('@getter').getChild('values')));
+ }
+
// TODO(scheglov) implement
// node.extendsClause?.accept(this);
// node.withClause?.accept(this);
@@ -231,12 +404,41 @@
// TODO(scheglov) don't create a duplicate
{
var holder2 = _buildClassMembers(element, node.members);
- element.accessors = holder2.propertyAccessors;
- element.fields = holder2.properties.whereType<FieldElement>().toList();
+ fields.addAll(
+ holder2.properties.whereType<FieldElementImpl>(),
+ );
+ accessors.addAll(
+ holder2.propertyAccessors,
+ );
// TODO(scheglov) implement
// element.methods = holder2.methods;
}
+ // TODO(scheglov) only if no explicit
+ MethodElementImpl toStringMethod;
+ {
+ toStringMethod = MethodElementImpl('toString', -1)..isSynthetic = true;
+ methods.add(toStringMethod);
+ toStringMethod.reference =
+ reference.getChild('@method').getChild('toString');
+ }
+
+ _libraryBuilder.implicitEnumNodes.add(
+ ImplicitEnumNodes(
+ element: element,
+ indexField: indexField,
+ valuesTypeNode: valuesTypeNode,
+ valuesField: valuesField,
+ constructorIndexParameter: constructorIndexParameter,
+ constructorNameParameter: constructorNameParameter,
+ syntheticToStringMethod: toStringMethod,
+ ),
+ );
+
+ element.accessors = accessors;
+ element.fields = fields;
+ element.methods = methods;
+
// TODO(scheglov) resolve field formals
}
@@ -1154,149 +1356,6 @@
}
}
- static void buildEnumChildren(
- Linker linker,
- LibraryElementImpl libraryElement,
- ) {
- for (var unitElement in libraryElement.units) {
- for (var element in unitElement.enums) {
- var node = linker.elementNodes[element] as EnumDeclaration;
- element as EnumElementImpl;
- var reference = element.reference!;
-
- var fields = <FieldElementImpl>[];
- var getters = <PropertyAccessorElementImpl>[];
-
- // Build the 'index' field.
- FieldElementImpl indexField;
- {
- var field = ConstFieldElementImpl('index', -1)
- ..enclosingElement = element
- ..isSynthetic = true
- ..isFinal = true
- ..type = libraryElement.typeProvider.intType;
- field.bindReference(
- reference.getChild('@field').getChild('index'),
- );
- indexField = field;
- fields.add(field);
- getters.add(PropertyAccessorElementImpl_ImplicitGetter(field,
- reference: reference.getChild('@getter').getChild('index'))
- ..enclosingElement = element);
- }
-
- var constructorReference =
- reference.getChild('@constructor').getChild('_');
- var constructor = ConstructorElementImpl('_', -1)
- ..isConst = true
- ..isSynthetic = true
- ..parameters = [
- FieldFormalParameterElementImpl(
- name: 'index',
- nameOffset: -1,
- parameterKind: ParameterKind.REQUIRED,
- )
- ..field = indexField
- ..type = libraryElement.typeProvider.intType,
- ParameterElementImpl(
- name: 'name',
- nameOffset: -1,
- parameterKind: ParameterKind.REQUIRED,
- )..type = libraryElement.typeProvider.stringType,
- ]
- ..reference = constructorReference;
- constructorReference.element = constructor;
- element.constructors = [constructor];
-
- // Build fields for all enum constants.
- var containerRef = reference.getChild('@field');
- var constants = node.constants;
- var valuesElements = <Expression>[];
- for (var i = 0; i < constants.length; ++i) {
- var constant = constants[i];
- var name = constant.name.name;
- var reference = containerRef.getChild(name);
- var field = ConstFieldElementImpl(name, constant.name.offset)
- ..isConst = true
- ..isEnumConstant = true
- ..isStatic = true
- ..type = element.thisType;
- _setCodeRange(field, constant);
- _setDocumentation(field, constant);
- field.reference = reference;
- field.metadata = _buildAnnotationsWithUnit(
- unitElement as CompilationUnitElementImpl,
- constant.metadata,
- );
- field.constantInitializer = astFactory.instanceCreationExpression(
- null,
- astFactory.constructorName(
- astFactory.namedType(
- name: astFactory.simpleIdentifier(
- StringToken(TokenType.STRING, element.name, -1),
- )..staticElement = element,
- )..type = element.thisType,
- null,
- null,
- )..staticElement = constructor,
- astFactory.argumentList(
- Tokens.openParenthesis(),
- [
- astFactory.integerLiteral(
- StringToken(TokenType.STRING, '$i', 0),
- i,
- )..staticType = libraryElement.typeProvider.intType,
- astFactory.simpleStringLiteral(
- StringToken(TokenType.STRING, "'$name'", 0),
- name,
- )..staticType = libraryElement.typeProvider.stringType,
- ],
- Tokens.closeParenthesis(),
- ),
- )..staticType = element.thisType;
- field.createImplicitAccessors(containerRef.parent!, name);
- fields.add(field);
- getters.add(field.getter as PropertyAccessorElementImpl);
- valuesElements.add(
- astFactory.simpleIdentifier(
- StringToken(TokenType.STRING, name, -1),
- )
- ..staticElement = field.getter
- ..staticType = element.thisType,
- );
- }
-
- // Build the 'values' field.
- {
- var type = libraryElement.typeProvider.listType(element.thisType);
- var field = ConstFieldElementImpl('values', -1)
- ..isConst = true
- ..isStatic = true
- ..isSynthetic = true
- ..type = type;
- field.constantInitializer = astFactory.listLiteral(
- null,
- null,
- Tokens.openSquareBracket(),
- valuesElements,
- Tokens.closeSquareBracket(),
- )..staticType = type;
- fields.add(field);
- getters.add(PropertyAccessorElementImpl_ImplicitGetter(field,
- reference: reference.getChild('@getter').getChild('values'))
- ..enclosingElement = element);
- }
-
- element.fields = fields;
- element.accessors = getters;
-
- element.createToStringMethodElement();
- (element.getMethod('toString') as MethodElementImpl).returnType =
- libraryElement.typeProvider.stringType;
- }
- }
- }
-
static List<ElementAnnotation> _buildAnnotationsWithUnit(
CompilationUnitElementImpl unitElement,
List<Annotation> nodeList,
diff --git a/pkg/analyzer/lib/src/summary2/element_flags.dart b/pkg/analyzer/lib/src/summary2/element_flags.dart
index 0d38935..e79b496 100644
--- a/pkg/analyzer/lib/src/summary2/element_flags.dart
+++ b/pkg/analyzer/lib/src/summary2/element_flags.dart
@@ -63,6 +63,7 @@
static const int _isFinal = 1 << 8;
static const int _isLate = 1 << 9;
static const int _isStatic = 1 << 10;
+ static const int _isSynthetic = 1 << 11;
static void read(SummaryDataReader reader, FieldElementImpl element) {
var byte = reader.readUInt30();
@@ -77,6 +78,7 @@
element.isFinal = (byte & _isFinal) != 0;
element.isLate = (byte & _isLate) != 0;
element.isStatic = (byte & _isStatic) != 0;
+ element.isSynthetic = (byte & _isSynthetic) != 0;
}
static void write(BufferedSink sink, FieldElementImpl element) {
@@ -92,6 +94,7 @@
result |= element.isFinal ? _isFinal : 0;
result |= element.isLate ? _isLate : 0;
result |= element.isStatic ? _isStatic : 0;
+ result |= element.isSynthetic ? _isSynthetic : 0;
sink.writeUInt30(result);
}
}
@@ -163,6 +166,7 @@
static const int _isExternal = 1 << 3;
static const int _isGenerator = 1 << 4;
static const int _isStatic = 1 << 5;
+ static const int _isSynthetic = 1 << 6;
static void read(SummaryDataReader reader, MethodElementImpl element) {
var byte = reader.readByte();
@@ -172,6 +176,7 @@
element.isExternal = (byte & _isExternal) != 0;
element.isGenerator = (byte & _isGenerator) != 0;
element.isStatic = (byte & _isStatic) != 0;
+ element.isSynthetic = (byte & _isSynthetic) != 0;
}
static void write(BufferedSink sink, MethodElementImpl element) {
@@ -182,6 +187,22 @@
result |= element.isExternal ? _isExternal : 0;
result |= element.isGenerator ? _isGenerator : 0;
result |= element.isStatic ? _isStatic : 0;
+ result |= element.isSynthetic ? _isSynthetic : 0;
+ sink.writeByte(result);
+ }
+}
+
+class MixinElementFlags {
+ static const int _isSimplyBounded = 1 << 0;
+
+ static void read(SummaryDataReader reader, MixinElementImpl element) {
+ var byte = reader.readByte();
+ element.isSimplyBounded = (byte & _isSimplyBounded) != 0;
+ }
+
+ static void write(BufferedSink sink, MixinElementImpl element) {
+ var result = 0;
+ result |= element.isSimplyBounded ? _isSimplyBounded : 0;
sink.writeByte(result);
}
}
diff --git a/pkg/analyzer/lib/src/summary2/library_builder.dart b/pkg/analyzer/lib/src/summary2/library_builder.dart
index f389647..c26e6f7 100644
--- a/pkg/analyzer/lib/src/summary2/library_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/library_builder.dart
@@ -20,6 +20,26 @@
import 'package:analyzer/src/summary2/scope.dart';
import 'package:analyzer/src/summary2/types_builder.dart';
+class ImplicitEnumNodes {
+ final EnumElementImpl element;
+ final FieldElementImpl indexField;
+ final ast.NamedTypeImpl valuesTypeNode;
+ final ConstFieldElementImpl valuesField;
+ final ParameterElementImpl constructorIndexParameter;
+ final ParameterElementImpl constructorNameParameter;
+ final MethodElementImpl syntheticToStringMethod;
+
+ ImplicitEnumNodes({
+ required this.element,
+ required this.indexField,
+ required this.valuesTypeNode,
+ required this.valuesField,
+ required this.constructorIndexParameter,
+ required this.constructorNameParameter,
+ required this.syntheticToStringMethod,
+ });
+}
+
class LibraryBuilder {
final Linker linker;
final Uri uri;
@@ -27,6 +47,8 @@
final LibraryElementImpl element;
final List<LinkingUnit> units;
+ final List<ImplicitEnumNodes> implicitEnumNodes = [];
+
/// Local declarations.
final Scope localScope = Scope.top();
@@ -114,7 +136,21 @@
}
void buildEnumChildren() {
- ElementBuilder.buildEnumChildren(linker, element);
+ var typeProvider = element.typeProvider;
+ for (var enum_ in implicitEnumNodes) {
+ enum_.indexField.type = typeProvider.intType;
+ var valuesType = typeProvider.listType(
+ element.typeSystem.instantiateToBounds2(
+ classElement: enum_.element,
+ nullabilitySuffix: typeProvider.objectType.nullabilitySuffix,
+ ),
+ );
+ enum_.valuesTypeNode.type = valuesType;
+ enum_.valuesField.type = valuesType;
+ enum_.constructorIndexParameter.type = typeProvider.intType;
+ enum_.constructorNameParameter.type = typeProvider.stringType;
+ enum_.syntheticToStringMethod.returnType = typeProvider.stringType;
+ }
}
void buildInitialExportScope() {
diff --git a/pkg/analyzer/lib/src/summary2/link.dart b/pkg/analyzer/lib/src/summary2/link.dart
index cf733cc..4526d92 100644
--- a/pkg/analyzer/lib/src/summary2/link.dart
+++ b/pkg/analyzer/lib/src/summary2/link.dart
@@ -88,8 +88,8 @@
void _buildOutlines() {
_computeLibraryScopes();
_createTypeSystem();
- _buildEnumChildren();
_resolveTypes();
+ _buildEnumChildren();
SuperConstructorResolver(this).perform();
_performTopLevelInference();
_resolveConstructors();
diff --git a/pkg/analyzer/lib/src/summary2/metadata_resolver.dart b/pkg/analyzer/lib/src/summary2/metadata_resolver.dart
index 286730c..63659bb7 100644
--- a/pkg/analyzer/lib/src/summary2/metadata_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/metadata_resolver.dart
@@ -28,7 +28,7 @@
void visitAnnotation(covariant AnnotationImpl node) {
var annotationElement = node.elementAnnotation;
if (annotationElement is ElementAnnotationImpl) {
- var astResolver = AstResolver(_linker, _unitElement, _scope, node);
+ var astResolver = AstResolver(_linker, _unitElement, _scope);
astResolver.resolveAnnotation(node);
annotationElement.element = node.element;
}
diff --git a/pkg/analyzer/lib/src/summary2/top_level_inference.dart b/pkg/analyzer/lib/src/summary2/top_level_inference.dart
index 714e348..9f2b66c 100644
--- a/pkg/analyzer/lib/src/summary2/top_level_inference.dart
+++ b/pkg/analyzer/lib/src/summary2/top_level_inference.dart
@@ -43,6 +43,7 @@
for (var unit in _library.units) {
_unitElement = unit as CompilationUnitElementImpl;
unit.classes.forEach(_resolveClassFields);
+ unit.enums.forEach(_resolveClassFields);
unit.extensions.forEach(_resolveExtensionFields);
unit.mixins.forEach(_resolveClassFields);
@@ -74,9 +75,9 @@
void _resolveVariable(PropertyInducingElement element) {
element as PropertyInducingElementImpl;
- if (element.isSynthetic) return;
- var variable = linker.getLinkingNode(element) as VariableDeclaration;
+ var variable = linker.getLinkingNode(element);
+ if (variable is! VariableDeclaration) return;
if (variable.initializer == null) return;
var declarationList = variable.parent as VariableDeclarationList;
@@ -93,8 +94,7 @@
if (declarationList.isConst ||
declarationList.isFinal && _enclosingClassHasConstConstructor) {
- var astResolver =
- AstResolver(linker, _unitElement, _scope, variable.initializer!);
+ var astResolver = AstResolver(linker, _unitElement, _scope);
astResolver.resolveExpression(() => variable.initializer!,
contextType: contextType);
}
@@ -351,6 +351,7 @@
_unitElement = unit as CompilationUnitElementImpl;
unit.classes.forEach(_addClassConstructorFieldFormals);
unit.classes.forEach(_addClassElementFields);
+ unit.enums.forEach(_addClassElementFields);
unit.extensions.forEach(_addExtensionElementFields);
unit.mixins.forEach(_addClassElementFields);
@@ -390,6 +391,7 @@
}
void _addVariableNode(PropertyInducingElement element) {
+ element as PropertyInducingElementImpl;
if (element.isSynthetic) return;
var node = _linker.getLinkingNode(element) as VariableDeclaration;
@@ -402,10 +404,10 @@
var inferenceNode =
_VariableInferenceNode(_walker, _unitElement, _scope, element, node);
_walker._nodes[element] = inferenceNode;
- (element as PropertyInducingElementImpl).typeInference =
+ element.typeInference =
_PropertyInducingElementTypeInference(inferenceNode);
} else {
- (element as PropertyInducingElementImpl).type = DynamicTypeImpl.instance;
+ element.type = DynamicTypeImpl.instance;
}
}
}
@@ -437,7 +439,7 @@
final CompilationUnitElementImpl _unitElement;
final TypeSystemImpl _typeSystem;
final Scope _scope;
- final PropertyInducingElement _element;
+ final PropertyInducingElementImpl _element;
final VariableDeclaration _node;
@override
@@ -456,13 +458,9 @@
return _node.name.name;
}
- PropertyInducingElementImpl get _elementImpl {
- return _node.declaredElement as PropertyInducingElementImpl;
- }
-
@override
List<_InferenceNode> computeDependencies() {
- if (_elementImpl.hasTypeInferred) {
+ if (_element.hasTypeInferred) {
return const <_InferenceNode>[];
}
@@ -480,7 +478,7 @@
@override
void evaluate() {
- if (_elementImpl.hasTypeInferred) {
+ if (_element.hasTypeInferred) {
return;
}
@@ -488,23 +486,23 @@
var initializerType = _node.initializer!.typeOrThrow;
initializerType = _refineType(initializerType);
- _elementImpl.type = initializerType;
- _elementImpl.hasTypeInferred = true;
+ _element.type = initializerType;
+ _element.hasTypeInferred = true;
isEvaluated = true;
}
@override
void markCircular(List<_InferenceNode> cycle) {
- _elementImpl.type = DynamicTypeImpl.instance;
- _elementImpl.hasTypeInferred = true;
+ _element.type = DynamicTypeImpl.instance;
+ _element.hasTypeInferred = true;
var cycleNames = <String>{};
for (var inferenceNode in cycle) {
cycleNames.add(inferenceNode.displayName);
}
- _elementImpl.typeInferenceError = TopLevelInferenceError(
+ _element.typeInferenceError = TopLevelInferenceError(
kind: TopLevelInferenceErrorKind.dependencyCycle,
arguments: cycleNames.toList(),
);
@@ -531,8 +529,7 @@
var enclosingElement = _element.enclosingElement;
var enclosingClassElement =
enclosingElement is ClassElement ? enclosingElement : null;
- var astResolver = AstResolver(
- _walker._linker, _unitElement, _scope, _node.initializer!,
+ var astResolver = AstResolver(_walker._linker, _unitElement, _scope,
enclosingClassElement: enclosingClassElement);
astResolver.resolveExpression(() => _node.initializer!,
buildElements: forDependencies);
diff --git a/pkg/analyzer/test/src/dart/resolution/enum_test.dart b/pkg/analyzer/test/src/dart/resolution/enum_test.dart
index 5b0bc4c..1fbf4d9 100644
--- a/pkg/analyzer/test/src/dart/resolution/enum_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/enum_test.dart
@@ -40,4 +40,20 @@
expect(findElement.field('index').isEnumConstant, isFalse);
expect(findElement.field('values').isEnumConstant, isFalse);
}
+
+ test_value_underscore() async {
+ await assertNoErrorsInCode(r'''
+enum E { _ }
+
+void f() {
+ E._.index;
+}
+''');
+
+ assertPropertyAccess2(
+ findNode.propertyAccess('index'),
+ element: findElement.getter('index', of: 'E'),
+ type: 'int',
+ );
+ }
}
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index 503b88a..4232bfc 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -8319,6 +8319,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -8343,6 +8348,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -8367,6 +8377,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -13582,6 +13597,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -13604,6 +13624,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -13626,6 +13651,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -15886,6 +15916,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -15908,6 +15943,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -15930,6 +15970,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -16025,6 +16070,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -17033,6 +17083,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -17055,6 +17110,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -17118,6 +17178,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -17140,6 +17205,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -17162,6 +17232,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -17461,6 +17536,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -17521,7 +17601,7 @@
synthetic final index @-1
type: int
static const enumConstant v @14
- type: E<T>
+ type: E<dynamic>
constantInitializer
InstanceCreationExpression
argumentList: ArgumentList
@@ -17534,26 +17614,35 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
- staticElement: self::@enum::E::@constructor::_
+ name: SimpleIdentifier
+ staticElement: ConstructorMember
+ base: self::@enum::E::@constructor::_
+ substitution: {T: dynamic}
+ staticType: null
+ token: _ @-1
+ period: . @0
+ staticElement: ConstructorMember
+ base: self::@enum::E::@constructor::_
+ substitution: {T: dynamic}
type: NamedType
name: SimpleIdentifier
staticElement: self::@enum::E
staticType: null
token: E @-1
- type: E<T>
- staticType: E<T>
+ type: E<dynamic>
+ staticType: E<dynamic>
synthetic static const values @-1
- type: List<E<T>>
+ type: List<E<dynamic>>
constantInitializer
ListLiteral
elements
SimpleIdentifier
staticElement: self::@enum::E::@getter::v
- staticType: E<T>
+ staticType: E<dynamic>
token: v @-1
leftBracket: [ @0
rightBracket: ] @0
- staticType: List<E<T>>
+ staticType: List<E<dynamic>>
constructors
synthetic const _ @-1
parameters
@@ -17566,9 +17655,9 @@
synthetic get index @-1
returnType: int
synthetic static get v @-1
- returnType: E<T>
+ returnType: E<dynamic>
synthetic static get values @-1
- returnType: List<E<T>>
+ returnType: List<E<dynamic>>
methods
synthetic toString @-1
returnType: String
@@ -17598,7 +17687,7 @@
synthetic final index @-1
type: int
static const enumConstant v @39
- type: E<T, U>
+ type: E<num, num>
constantInitializer
InstanceCreationExpression
argumentList: ArgumentList
@@ -17611,26 +17700,35 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
- staticElement: self::@enum::E::@constructor::_
+ name: SimpleIdentifier
+ staticElement: ConstructorMember
+ base: self::@enum::E::@constructor::_
+ substitution: {T: num, U: num}
+ staticType: null
+ token: _ @-1
+ period: . @0
+ staticElement: ConstructorMember
+ base: self::@enum::E::@constructor::_
+ substitution: {T: num, U: num}
type: NamedType
name: SimpleIdentifier
staticElement: self::@enum::E
staticType: null
token: E @-1
- type: E<T, U>
- staticType: E<T, U>
+ type: E<num, num>
+ staticType: E<num, num>
synthetic static const values @-1
- type: List<E<T, U>>
+ type: List<E<num, num>>
constantInitializer
ListLiteral
elements
SimpleIdentifier
staticElement: self::@enum::E::@getter::v
- staticType: E<T, U>
+ staticType: E<num, num>
token: v @-1
leftBracket: [ @0
rightBracket: ] @0
- staticType: List<E<T, U>>
+ staticType: List<E<num, num>>
constructors
synthetic const _ @-1
parameters
@@ -17643,9 +17741,9 @@
synthetic get index @-1
returnType: int
synthetic static get v @-1
- returnType: E<T, U>
+ returnType: E<num, num>
synthetic static get values @-1
- returnType: List<E<T, U>>
+ returnType: List<E<num, num>>
methods
synthetic toString @-1
returnType: String
@@ -17670,12 +17768,12 @@
synthetic final index @-1
type: int
synthetic static const values @-1
- type: List<E<T>>
+ type: List<E<dynamic>>
constantInitializer
ListLiteral
leftBracket: [ @0
rightBracket: ] @0
- staticType: List<E<T>>
+ staticType: List<E<dynamic>>
constructors
synthetic const _ @-1
parameters
@@ -17688,7 +17786,7 @@
synthetic get index @-1
returnType: int
synthetic static get values @-1
- returnType: List<E<T>>
+ returnType: List<E<dynamic>>
methods
synthetic toString @-1
returnType: String
@@ -17719,12 +17817,12 @@
synthetic final index @-1
type: int
synthetic static const values @-1
- type: List<E<T, U, V>>
+ type: List<E<dynamic, num, dynamic>>
constantInitializer
ListLiteral
leftBracket: [ @0
rightBracket: ] @0
- staticType: List<E<T, U, V>>
+ staticType: List<E<dynamic, num, dynamic>>
constructors
synthetic const _ @-1
parameters
@@ -17737,7 +17835,7 @@
synthetic get index @-1
returnType: int
synthetic static get values @-1
- returnType: List<E<T, U, V>>
+ returnType: List<E<dynamic, num, dynamic>>
methods
synthetic toString @-1
returnType: String
@@ -17762,12 +17860,12 @@
synthetic final index @-1
type: int
synthetic static const values @-1
- type: List<E<T>>
+ type: List<E<dynamic>>
constantInitializer
ListLiteral
leftBracket: [ @0
rightBracket: ] @0
- staticType: List<E<T>>
+ staticType: List<E<dynamic>>
constructors
synthetic const _ @-1
parameters
@@ -17780,7 +17878,7 @@
synthetic get index @-1
returnType: int
synthetic static get values @-1
- returnType: List<E<T>>
+ returnType: List<E<dynamic>>
methods
synthetic toString @-1
returnType: String
@@ -17804,12 +17902,12 @@
synthetic final index @-1
type: int
synthetic static const values @-1
- type: List<E<T>>
+ type: List<E<dynamic>>
constantInitializer
ListLiteral
leftBracket: [ @0
rightBracket: ] @0
- staticType: List<E<T>>
+ staticType: List<E<dynamic>>
constructors
synthetic const _ @-1
parameters
@@ -17822,7 +17920,7 @@
synthetic get index @-1
returnType: int
synthetic static get values @-1
- returnType: List<E<T>>
+ returnType: List<E<dynamic>>
methods
synthetic toString @-1
returnType: String
@@ -17846,12 +17944,12 @@
synthetic final index @-1
type: int
synthetic static const values @-1
- type: List<E<T>>
+ type: List<E<dynamic>>
constantInitializer
ListLiteral
leftBracket: [ @0
rightBracket: ] @0
- staticType: List<E<T>>
+ staticType: List<E<dynamic>>
constructors
synthetic const _ @-1
parameters
@@ -17864,7 +17962,7 @@
synthetic get index @-1
returnType: int
synthetic static get values @-1
- returnType: List<E<T>>
+ returnType: List<E<dynamic>>
methods
synthetic toString @-1
returnType: String
@@ -17888,12 +17986,12 @@
synthetic final index @-1
type: int
synthetic static const values @-1
- type: List<E<T>>
+ type: List<E<dynamic>>
constantInitializer
ListLiteral
leftBracket: [ @0
rightBracket: ] @0
- staticType: List<E<T>>
+ staticType: List<E<dynamic>>
constructors
synthetic const _ @-1
parameters
@@ -17906,7 +18004,7 @@
synthetic get index @-1
returnType: int
synthetic static get values @-1
- returnType: List<E<T>>
+ returnType: List<E<dynamic>>
methods
synthetic toString @-1
returnType: String
@@ -17934,12 +18032,12 @@
synthetic final index @-1
type: int
synthetic static const values @-1
- type: List<E<T, U, V>>
+ type: List<E<dynamic, dynamic, dynamic>>
constantInitializer
ListLiteral
leftBracket: [ @0
rightBracket: ] @0
- staticType: List<E<T, U, V>>
+ staticType: List<E<dynamic, dynamic, dynamic>>
constructors
synthetic const _ @-1
parameters
@@ -17952,7 +18050,7 @@
synthetic get index @-1
returnType: int
synthetic static get values @-1
- returnType: List<E<T, U, V>>
+ returnType: List<E<dynamic, dynamic, dynamic>>
methods
synthetic toString @-1
returnType: String
@@ -17993,6 +18091,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -18016,6 +18119,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -18110,6 +18218,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -18141,6 +18254,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -18198,6 +18316,81 @@
''');
}
+ test_enum_value_underscore() async {
+ var library = await checkLibrary('''
+enum E {
+ _
+}
+''');
+ checkElementText(library, r'''
+library
+ definingUnit
+ enums
+ enum E @5
+ supertype: Enum
+ fields
+ synthetic final index @-1
+ type: int
+ static const enumConstant _ @11
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: '_' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_1
+ staticType: null
+ token: _1 @-1
+ period: . @0
+ staticElement: self::@enum::E::@constructor::_1
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ synthetic static const values @-1
+ type: List<E>
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::_
+ staticType: E
+ token: _ @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _1 @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
+ accessors
+ synthetic get index @-1
+ returnType: int
+ synthetic static get _ @-1
+ returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
+ methods
+ synthetic toString @-1
+ returnType: String
+''');
+ }
+
test_enum_values() async {
var library = await checkLibrary('enum E { v1, v2 }');
checkElementText(library, r'''
@@ -18223,6 +18416,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -18245,6 +18443,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -18317,6 +18520,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E1::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E1::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -18374,6 +18582,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E2::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E2::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -18498,6 +18711,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -18520,6 +18738,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -18542,6 +18765,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -25451,6 +25679,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -25567,6 +25800,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -25589,6 +25827,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -25626,6 +25869,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -25712,6 +25960,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -27257,6 +27510,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -27279,6 +27537,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -27309,6 +27572,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -28579,6 +28847,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -28601,6 +28874,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -28623,6 +28901,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -29977,6 +30260,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -30000,6 +30288,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -32016,6 +32309,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -32161,6 +32459,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -32240,6 +32543,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -32356,6 +32664,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -32470,6 +32783,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
@@ -32652,6 +32970,11 @@
leftParenthesis: ( @0
rightParenthesis: ) @0
constructorName: ConstructorName
+ name: SimpleIdentifier
+ staticElement: self::@enum::E::@constructor::_
+ staticType: null
+ token: _ @-1
+ period: . @0
staticElement: self::@enum::E::@constructor::_
type: NamedType
name: SimpleIdentifier
diff --git a/tools/VERSION b/tools/VERSION
index dc4983b..5c751de 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 17
PATCH 0
-PRERELEASE 13
+PRERELEASE 14
PRERELEASE_PATCH 0
\ No newline at end of file