Augment. Deprecate ExtensionTypeDeclaration.primaryConstructor, use namePart instead.

Extension type augmentations do not have representation declarations, so
an `ExtensionTypeDeclaration` can no longer always expose its name
through a primary constructor. Add `ExtensionTypeDeclaration.namePart`
as the canonical API for the declared name and type parameters, and keep
`primaryConstructor` as a deprecated compatibility API for introductory
declarations.

Report `extensionTypeAugmentationHasRepresentation` when an augmentation
writes representation syntax. This keeps the parser recovery explicit:
the augmentation still gets a plain `namePart`, while the invalid
representation is diagnosed instead of being modeled as the
declaration's primary constructor.

Synthesize recovery representation and primary constructor fragments
only for the element model when an extension type has no introductory
declaration.

Migrate analyzer, analysis server, analyzer plugin, and linter clients
to read extension type names and type parameters from `namePart`.

Change-Id: I59dd957ac38f087c861b993caf246986dcdac713
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505067
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov
2026-05-26 10:05:28 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent cf5494aa89
commit 8c6366e66e
59 changed files with 1001 additions and 579 deletions
@@ -296,7 +296,7 @@ class _DartDocumentHighlightsVisitor extends GeneralizingAstVisitor<void> {
void visitExtensionTypeDeclaration(ExtensionTypeDeclaration node) {
_addOccurrence(
node.declaredFragment?.element,
node.primaryConstructor.typeName,
node.namePart.typeName,
.Write,
);
@@ -1127,7 +1127,7 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor<void> {
computer._addRegion_token(node.typeKeyword, HighlightRegionType.KEYWORD);
computer._addRegion_token(
node.primaryConstructor.typeName,
node.namePart.typeName,
HighlightRegionType.EXTENSION_TYPE,
semanticTokenModifiers: {SemanticTokenModifiers.declaration},
);
@@ -237,7 +237,7 @@ class DartUnitHoverComputer {
EnumDeclaration() => node.namePart.typeName,
Expression() => node,
ExtensionDeclaration() => node.name,
ExtensionTypeDeclaration() => node.primaryConstructor.typeName,
ExtensionTypeDeclaration() => node.namePart.typeName,
FormalParameter() => node.name,
FunctionDeclaration() => node.name,
ImportPrefixReference() => node.name,
@@ -325,7 +325,7 @@ class DartUnitOutlineComputer {
ExtensionTypeDeclaration node,
List<Outline> extensionContents,
) {
var nameToken = node.primaryConstructor.typeName;
var nameToken = node.namePart.typeName;
var name = nameToken.lexeme;
var element = Element(
ElementKind.EXTENSION_TYPE,
@@ -335,9 +335,7 @@ class DartUnitOutlineComputer {
isDeprecated: _hasDeprecated(node.metadata),
),
location: _getLocationToken(nameToken),
typeParameters: _getTypeParametersStr(
node.primaryConstructor.typeParameters,
),
typeParameters: _getTypeParametersStr(node.namePart.typeParameters),
);
return _nodeOutline(node, element, extensionContents);
}
@@ -152,10 +152,7 @@ class DartUnitOccurrencesComputerVisitor extends GeneralizingAstVisitor<void> {
@override
void visitExtensionTypeDeclaration(ExtensionTypeDeclaration node) {
_addOccurrence(
node.declaredFragment!.element,
node.primaryConstructor.typeName,
);
_addOccurrence(node.declaredFragment!.element, node.namePart.typeName);
super.visitExtensionTypeDeclaration(node);
}
@@ -1332,12 +1332,14 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
return;
}
var namePart = node.namePart;
if (offset == node.offset) {
_forCompilationUnitMemberBefore(node);
} else if (offset <= node.primaryConstructor.typeName.end) {
if (offset < node.primaryConstructor.typeName.offset &&
} else if (offset <= namePart.typeName.end) {
if (offset < namePart.typeName.offset &&
featureSet.isEnabled(Feature.primary_constructors) &&
!node.primaryConstructor.hasConst) {
namePart is PrimaryConstructorDeclaration &&
!namePart.hasConst) {
keywordHelper.addKeyword(Keyword.CONST);
}
var hasSyntheticBody =
@@ -1345,7 +1347,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
identifierHelper(
includePrivateIdentifiers: false,
).addTopLevelName(includeBody: hasSyntheticBody);
} else if (offset >= node.primaryConstructor.end &&
} else if (offset >= namePart.end &&
(offset <= body.leftBracket.offset || body.leftBracket.isSynthetic)) {
keywordHelper.addKeyword(Keyword.IMPLEMENTS);
} else if (offset >= body.leftBracket.end &&
@@ -188,7 +188,7 @@ class MemberSorter {
name = member.namePart.typeName.lexeme;
case ExtensionTypeDeclaration():
kind = _MemberKind.unitExtensionType;
name = member.primaryConstructor.typeName.lexeme;
name = member.namePart.typeName.lexeme;
case ExtensionDeclaration():
kind = _MemberKind.unitExtension;
name = member.name?.lexeme ?? '';
@@ -622,7 +622,7 @@ abstract class RenameRefactoring implements Refactoring {
} else if (node is EnumDeclaration) {
nameNode = node.namePart.typeName;
} else if (node is ExtensionTypeDeclaration) {
nameNode = node.primaryConstructor.typeName;
nameNode = node.namePart.typeName;
} else if (node is FunctionDeclaration) {
nameNode = node.name;
} else if (node is MixinDeclaration) {
@@ -279,7 +279,7 @@ class MoveTopLevelToFile extends ParameterizedRefactoringProducer {
return null;
}
case ExtensionTypeDeclaration():
nameToken = node.primaryConstructor.typeName;
nameToken = node.namePart.typeName;
if (!validSelection(nameToken)) {
return null;
}
@@ -978,7 +978,7 @@ class RelevanceDataCollector extends RecursiveAstVisitor<void> {
// No other completions are valid after `extension`.
_unrecorded(node.typeKeyword);
_recordDeclaration(node.primaryConstructor.typeName);
_recordDeclaration(node.namePart.typeName);
for (var member in node.body.members) {
_recordDataForNode(
+2 -1
View File
@@ -3,6 +3,7 @@
* Deprecate `PackageConfigFileBuilder` in `package:analyzer/utilities/package_config_file_builder.dart`. Use `package:analyzer_testing/package_config_file_builder.dart` instead.
* Deprecate `isInitializingFormal` in `FormalParameterElement`. Use type checks (`element is FieldFormalParameterElement`) instead.
* Deprecate `isSuperFormal` in `FormalParameterElement`. Use type checks (`element is SuperFormalParameterElement`) instead.
* Deprecate `ExtensionTypeDeclaration.primaryConstructor`. Use `ExtensionTypeDeclaration.namePart` instead.
## 13.0.0
@@ -337,7 +338,7 @@
* Deprecate `InterfaceType.lookUpGetter3`, use `lookUpGetter` instead.
* Deprecate `InterfaceType.lookUpMethod3`, use `lookUpMethod` instead.
* Deprecate `InterfaceType.lookUpSetter3`, use `lookUpSetter` instead.
* Remove `PropertyAccessorFragmentImplImplicitGetter`, `PropertyAccessorFragmentImplImplicitSetter`,
* Remove `PropertyAccessorFragmentImplImplicitGetter`, `PropertyAccessorFragmentImplImplicitSetter`,
and `FormalParameterFragmentImplOfImplicitSetter`, replace with `GetterFragmentImpl`, and `SetterFragmentImpl`.
* Deprecate `ExtensionTypeFragment.representation2`, use `representation` instead.
* Deprecate `DartType.element3`, use `element` instead.
+4 -1
View File
@@ -1133,7 +1133,8 @@ package:analyzer/dart/ast/ast.dart:
declaredFragment (getter: ExtensionTypeFragment?)
extensionKeyword (getter: Token)
implementsClause (getter: ImplementsClause?)
primaryConstructor (getter: PrimaryConstructorDeclaration)
namePart (getter: ClassNamePart)
primaryConstructor (getter: PrimaryConstructorDeclaration, deprecated)
typeKeyword (getter: Token)
FieldDeclaration (class extends Object implements ClassMember, abstract, final):
abstractKeyword (getter: Token?)
@@ -3393,6 +3394,7 @@ package:analyzer/dart/element/element.dart:
isFactory (getter: bool)
isGenerative (getter: bool)
isOriginDeclaration (getter: bool)
isOriginExtensionTypeRecovery (getter: bool)
isOriginImplicitDefault (getter: bool)
isOriginMixinApplication (getter: bool)
isPrimary (getter: bool)
@@ -3405,6 +3407,7 @@ package:analyzer/dart/element/element.dart:
element (getter: ConstructorElement)
enclosingFragment (getter: InstanceFragment?)
factoryKeywordOffset (getter: int?)
isOriginExtensionTypeRecovery (getter: bool)
name (getter: String)
newKeywordOffset (getter: int?)
nextFragment (getter: ConstructorFragment?)
+15 -8
View File
@@ -241,21 +241,24 @@ abstract class ConstructorElement implements ExecutableElement {
/// Whether the constructor is from an explicit [ConstructorDeclaration]
/// or [PrimaryConstructorDeclaration].
///
/// When this is `true`, [isOriginImplicitDefault] and
/// [isOriginMixinApplication] are `false`.
/// Constructor origin getters are mutually exclusive. Exactly one of the
/// following is `true`:
///
/// * [isOriginDeclaration]
/// * [isOriginExtensionTypeRecovery]
/// * [isOriginImplicitDefault]
/// * [isOriginMixinApplication]
bool get isOriginDeclaration;
/// Whether the constructor represents the recovery constructor of an extension
/// type when no introductory declaration is present in the library.
bool get isOriginExtensionTypeRecovery;
/// Whether the constructor was created because there are no explicit
/// constructors.
///
/// When this is `true`, [isOriginDeclaration] and
/// [isOriginMixinApplication] are `false`.
bool get isOriginImplicitDefault;
/// Whether the constructor was created for a mixin application.
///
/// When this is `true`, [isOriginDeclaration] and
/// [isOriginImplicitDefault] are `false`.
bool get isOriginMixinApplication;
/// Whether this is a primary constructor.
@@ -298,6 +301,10 @@ abstract class ConstructorFragment implements ExecutableFragment {
/// It is `null` if the fragment is synthetic, or does not have the keyword.
int? get factoryKeywordOffset;
/// Whether the constructor represents the recovery constructor of an extension
/// type when no introductory declaration is present in the library.
bool get isOriginExtensionTypeRecovery;
@override
String get name;
@@ -64,11 +64,14 @@ DefinedNames computeDefinedNames(CompilationUnitImpl unit) {
appendName(names.topLevelNames, member.name);
member.body.members.forEach(appendClassMemberName);
case ExtensionTypeDeclarationImpl():
appendName(names.topLevelNames, member.primaryConstructor.typeName);
appendDeclaringFormalParameterNames(
member.primaryConstructor,
isExtensionType: true,
);
appendName(names.topLevelNames, member.namePart.typeName);
if (member.namePart
case PrimaryConstructorDeclarationImpl primaryConstructor) {
appendDeclaringFormalParameterNames(
primaryConstructor,
isExtensionType: true,
);
}
member.body.members.forEach(appendClassMemberName);
case FunctionDeclarationImpl():
appendName(names.topLevelNames, member.name);
@@ -109,7 +109,7 @@ testFineAfterLibraryAnalyzerHook;
// TODO(scheglov): Clean up the list of implicitly analyzed files.
class AnalysisDriver {
/// The version of data format, should be incremented on every format change.
static const int DATA_VERSION = 636;
static const int DATA_VERSION = 637;
/// The number of exception contexts allowed to write. Once this field is
/// zero, we stop writing any new exception contexts in this process.
@@ -1030,9 +1030,7 @@ class FileState {
topLevelDeclarations.add(name.lexeme);
}
} else if (declaration is ExtensionTypeDeclaration) {
topLevelDeclarations.add(
declaration.primaryConstructor.typeName.lexeme,
);
topLevelDeclarations.add(declaration.namePart.typeName.lexeme);
} else if (declaration is FunctionDeclaration) {
topLevelDeclarations.add(declaration.name.lexeme);
} else if (declaration is MixinDeclaration) {
@@ -915,7 +915,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
covariant ExtensionTypeDeclarationImpl node,
) {
_addSubtype(
node.primaryConstructor.typeName.lexeme,
node.namePart.typeName.lexeme,
implementsClause: node.implementsClause,
memberNodes: node.body.members,
);
@@ -109,7 +109,7 @@ class _LocalNameScope {
ExtensionTypeDeclarationImpl node,
) {
var scope = _LocalNameScope(enclosing);
scope.addTypeParameters(node.primaryConstructor.typeParameters);
scope.addTypeParameters(node.namePart.typeParameters);
for (ClassMember member in node.body.members) {
if (member is FieldDeclaration) {
scope.addVariableNames(member.fields);
@@ -160,7 +160,7 @@ class _LocalNameScope {
case ExtensionDeclaration():
scope.add(declaration.name);
case ExtensionTypeDeclaration():
scope.add(declaration.primaryConstructor.typeName);
scope.add(declaration.namePart.typeName);
case FunctionDeclaration():
scope.add(declaration.name);
case MixinDeclaration():
@@ -90,7 +90,7 @@ class DeclarationByElementLocator extends UnifyingAstVisitor<void> {
result = node;
}
} else if (node is ExtensionTypeDeclaration) {
if (_hasOffset(node.primaryConstructor.typeName)) {
if (_hasOffset(node.namePart.typeName)) {
result = node;
}
}
+42 -24
View File
@@ -12116,7 +12116,17 @@ abstract final class ExtensionTypeDeclaration implements CompilationUnitMember {
/// The `implements` clause.
ImplementsClause? get implementsClause;
/// The name of the extension type. In valid code the introductory declaration
/// has [PrimaryConstructorDeclaration], and augmentations have
/// [NameWithTypeParameters].
ClassNamePart get namePart;
/// The primary constructor of the extension type.
///
/// Use [namePart] instead. It is a [PrimaryConstructorDeclaration] for an
/// introductory declaration with a primary constructor, and a
/// [NameWithTypeParameters] for an augmentation.
@Deprecated('Use namePart instead')
PrimaryConstructorDeclaration get primaryConstructor;
/// The `type` keyword.
@@ -12128,7 +12138,7 @@ abstract final class ExtensionTypeDeclaration implements CompilationUnitMember {
GenerateNodeProperty('augmentKeyword'),
GenerateNodeProperty('extensionKeyword'),
GenerateNodeProperty('typeKeyword'),
GenerateNodeProperty('primaryConstructor'),
GenerateNodeProperty('namePart'),
GenerateNodeProperty('implementsClause'),
GenerateNodeProperty('body'),
],
@@ -12149,7 +12159,7 @@ final class ExtensionTypeDeclarationImpl extends CompilationUnitMemberImpl
final Token typeKeyword;
@generated
PrimaryConstructorDeclarationImpl _primaryConstructor;
ClassNamePartImpl _namePart;
@generated
ImplementsClauseImpl? _implementsClause;
@@ -12169,13 +12179,13 @@ final class ExtensionTypeDeclarationImpl extends CompilationUnitMemberImpl
required this.augmentKeyword,
required this.extensionKeyword,
required this.typeKeyword,
required PrimaryConstructorDeclarationImpl primaryConstructor,
required ClassNamePartImpl namePart,
required ImplementsClauseImpl? implementsClause,
required ClassBodyImpl body,
}) : _primaryConstructor = primaryConstructor,
}) : _namePart = namePart,
_implementsClause = implementsClause,
_body = body {
_becomeParentOf(primaryConstructor);
_becomeParentOf(namePart);
_becomeParentOf(implementsClause);
_becomeParentOf(body);
}
@@ -12215,17 +12225,27 @@ final class ExtensionTypeDeclarationImpl extends CompilationUnitMemberImpl
@generated
@override
PrimaryConstructorDeclarationImpl get primaryConstructor =>
_primaryConstructor;
ClassNamePartImpl get namePart => _namePart;
@generated
set primaryConstructor(PrimaryConstructorDeclarationImpl primaryConstructor) {
_primaryConstructor = _becomeParentOf(primaryConstructor);
set namePart(ClassNamePartImpl namePart) {
_namePart = _becomeParentOf(namePart);
}
@override
@Deprecated('Use namePart instead')
PrimaryConstructorDeclarationImpl get primaryConstructor =>
namePart as PrimaryConstructorDeclarationImpl;
/// Usually, the only formal parameter of the primary constructor.
/// But could be `null` in invalid code.
RegularFormalParameterImpl? get representationFormalParameter {
var primaryConstructor = namePart
.tryCast<PrimaryConstructorDeclarationImpl>();
if (primaryConstructor == null) {
return null;
}
var formalParameters = primaryConstructor.formalParameters;
return formalParameters.parameters.firstOrNull.tryCast();
}
@@ -12236,7 +12256,7 @@ final class ExtensionTypeDeclarationImpl extends CompilationUnitMemberImpl
..addToken('augmentKeyword', augmentKeyword)
..addToken('extensionKeyword', extensionKeyword)
..addToken('typeKeyword', typeKeyword)
..addNode('primaryConstructor', primaryConstructor)
..addNode('namePart', namePart)
..addNode('implementsClause', implementsClause)
..addNode('body', body);
@@ -12255,10 +12275,8 @@ final class ExtensionTypeDeclarationImpl extends CompilationUnitMemberImpl
@generated
@override
void removeChild(AstNodeImpl oldNode) {
if (identical(primaryConstructor, oldNode)) {
throw UnsupportedError(
"Cannot remove required child 'primaryConstructor'.",
);
if (identical(namePart, oldNode)) {
throw UnsupportedError("Cannot remove required child 'namePart'.");
}
if (identical(implementsClause, oldNode)) {
implementsClause = null;
@@ -12273,8 +12291,8 @@ final class ExtensionTypeDeclarationImpl extends CompilationUnitMemberImpl
@generated
@override
void replaceChild(AstNodeImpl oldNode, AstNodeImpl newNode) {
if (identical(primaryConstructor, oldNode)) {
primaryConstructor = newNode as PrimaryConstructorDeclarationImpl;
if (identical(namePart, oldNode)) {
namePart = newNode as ClassNamePartImpl;
return;
}
if (identical(implementsClause, oldNode)) {
@@ -12292,7 +12310,7 @@ final class ExtensionTypeDeclarationImpl extends CompilationUnitMemberImpl
@override
void visitChildren(AstVisitor visitor) {
super.visitChildren(visitor);
primaryConstructor.accept(visitor);
namePart.accept(visitor);
implementsClause?.accept(visitor);
body.accept(visitor);
}
@@ -12305,15 +12323,15 @@ final class ExtensionTypeDeclarationImpl extends CompilationUnitMemberImpl
@generated
void visitChildrenWithHooks(
AstVisitor visitor, {
void Function(PrimaryConstructorDeclarationImpl)? visitPrimaryConstructor,
void Function(ClassNamePartImpl)? visitNamePart,
void Function(ImplementsClauseImpl)? visitImplementsClause,
void Function(ClassBodyImpl)? visitBody,
}) {
super.visitChildren(visitor);
if (visitPrimaryConstructor != null) {
visitPrimaryConstructor(primaryConstructor);
if (visitNamePart != null) {
visitNamePart(namePart);
} else {
primaryConstructor.accept(visitor);
namePart.accept(visitor);
}
if (implementsClause case var implementsClause?) {
if (visitImplementsClause != null) {
@@ -12335,8 +12353,8 @@ final class ExtensionTypeDeclarationImpl extends CompilationUnitMemberImpl
if (super._childContainingRange(rangeOffset, rangeEnd) case var result?) {
return result;
}
if (primaryConstructor._containsOffset(rangeOffset, rangeEnd)) {
return primaryConstructor;
if (namePart._containsOffset(rangeOffset, rangeEnd)) {
return namePart;
}
if (implementsClause case var implementsClause?) {
if (implementsClause._containsOffset(rangeOffset, rangeEnd)) {
@@ -26808,7 +26826,7 @@ final class PrimaryConstructorBodyImpl extends ClassMemberImpl
case EnumDeclarationImpl parent:
return parent.namePart.tryCast();
case ExtensionTypeDeclarationImpl parent:
return parent.primaryConstructor;
return parent.namePart.tryCast();
default:
return null;
}
@@ -523,7 +523,7 @@ class ToSourceVisitor implements AstVisitor<void> {
_visitToken(node.augmentKeyword, suffix: ' ');
_visitToken(node.extensionKeyword, suffix: ' ');
_visitToken(node.typeKeyword, suffix: ' ');
_visitNode(node.primaryConstructor);
_visitNode(node.namePart);
_visitNode(node.implementsClause, prefix: ' ');
_visitNode(node.body);
}
@@ -871,6 +871,7 @@ class ConstructorElementImpl extends ExecutableElementImpl
'isConst': isConst,
'isFactory': isFactory,
'isOriginDeclaration': isOriginDeclaration,
'isOriginExtensionTypeRecovery': isOriginExtensionTypeRecovery,
'isOriginImplicitDefault': isOriginImplicitDefault,
'isOriginMixinApplication': isOriginMixinApplication,
'isPrimary': isPrimary,
@@ -917,6 +918,13 @@ class ConstructorElementImpl extends ExecutableElementImpl
return _firstFragment.isOriginDeclaration;
}
@generated
@override
@trackedIncludedInId
bool get isOriginExtensionTypeRecovery {
return _firstFragment.isOriginExtensionTypeRecovery;
}
@generated
@override
@trackedIncludedInId
@@ -1170,6 +1178,7 @@ class ConstructorFragmentImpl extends ExecutableFragmentImpl
'isConst': isConst,
'isFactory': isFactory,
'isOriginDeclaration': isOriginDeclaration,
'isOriginExtensionTypeRecovery': isOriginExtensionTypeRecovery,
'isOriginImplicitDefault': isOriginImplicitDefault,
'isOriginMixinApplication': isOriginMixinApplication,
'isPrimary': isPrimary,
@@ -1233,6 +1242,22 @@ class ConstructorFragmentImpl extends ExecutableFragmentImpl
);
}
@generated
@override
bool get isOriginExtensionTypeRecovery {
return hasFlag(
_FragmentStorageFlag.constructorFragment_isOriginExtensionTypeRecovery,
);
}
@generated
set isOriginExtensionTypeRecovery(bool value) {
setFlag(
_FragmentStorageFlag.constructorFragment_isOriginExtensionTypeRecovery,
value,
);
}
@generated
bool get isOriginImplicitDefault {
return hasFlag(
@@ -11910,6 +11935,10 @@ enum _ConstructorElementFlags {
fragment: true,
element: _ElementFlagSource.firstFragment,
),
isOriginExtensionTypeRecovery(
fragment: true,
element: _ElementFlagSource.firstFragment,
),
isOriginImplicitDefault(
fragment: true,
element: _ElementFlagSource.firstFragment,
@@ -12055,6 +12084,7 @@ enum _FragmentStorageFlag {
constructorFragment_isConst,
constructorFragment_isFactory,
constructorFragment_isOriginDeclaration,
constructorFragment_isOriginExtensionTypeRecovery,
constructorFragment_isOriginImplicitDefault,
constructorFragment_isOriginMixinApplication,
constructorFragment_isPrimary,
@@ -61,6 +61,10 @@ class SubstitutedConstructorElementImpl extends SubstitutedExecutableElementImpl
@override
bool get isOriginDeclaration => baseElement.isOriginDeclaration;
@override
bool get isOriginExtensionTypeRecovery =>
baseElement.isOriginExtensionTypeRecovery;
@override
bool get isOriginImplicitDefault => baseElement.isOriginImplicitDefault;
@@ -198,18 +198,24 @@ class ScopeContext {
withTypeParameterScope(element.typeParameters, () {
node.nameScope = nameScope;
node.primaryConstructor.typeParameters?.accept(visitor);
node.namePart.typeParameters?.accept(visitor);
node.implementsClause?.accept(visitor);
if (_featureSet.isEnabled(Feature.primary_constructors)) {
withInstanceScope(element, () {
node.bodyScope = nameScope;
node.documentationComment?.accept(visitor);
node.primaryConstructor.formalParameters.accept(visitor);
node.namePart
.tryCast<PrimaryConstructorDeclarationImpl>()
?.formalParameters
.accept(visitor);
node.body.accept(visitor);
});
} else {
node.primaryConstructor.formalParameters.accept(visitor);
node.namePart
.tryCast<PrimaryConstructorDeclarationImpl>()
?.formalParameters
.accept(visitor);
withInstanceScope(element, () {
node.bodyScope = nameScope;
node.documentationComment?.accept(visitor);
@@ -237,7 +237,7 @@ class DuplicateDefinitionVerifier {
if (!declaredFragment.isAugmentation) {
_checkDuplicateFragmentIdentifier(
definedGetters,
member.primaryConstructor.typeName,
member.namePart.typeName,
fragment: declaredFragment,
);
}
@@ -522,7 +522,7 @@ class MemberDuplicateDefinitionVerifier {
_checkClassMembers(
node.declaredFragment!,
node.body.members,
primaryConstructor: node.primaryConstructor,
primaryConstructor: node.namePart.tryCast(),
);
}
@@ -104,8 +104,7 @@ class WidgetPreviewVerifier {
ClassDeclaration declaration => declaration.namePart.typeName,
EnumDeclaration declaration => declaration.namePart.typeName,
ExtensionDeclaration declaration => declaration.name,
ExtensionTypeDeclaration declaration =>
declaration.primaryConstructor.typeName,
ExtensionTypeDeclaration declaration => declaration.namePart.typeName,
MixinDeclaration declaration => declaration.name,
_ => null,
};
+12 -9
View File
@@ -1587,11 +1587,13 @@ class AstBuilder extends StackListener {
if (enableInlineClass) {
var builder = _classLikeBuilder as _ExtensionTypeDeclarationBuilder;
primaryConstructorBuilder ??= _PrimaryConstructorBuilder(
constKeyword: null,
constructorName: null,
formalParameterList: _syntheticFormalParameterList(builder.name),
);
if (builder.augmentKeyword == null) {
primaryConstructorBuilder ??= _PrimaryConstructorBuilder(
constKeyword: null,
constructorName: null,
formalParameterList: _syntheticFormalParameterList(builder.name),
);
}
declarations.add(
builder.build(
@@ -2714,6 +2716,7 @@ class AstBuilder extends StackListener {
case DeclarationKind.ExtensionType:
// Always valid.
break;
case DeclarationKind.Class:
case DeclarationKind.Enum:
if (!_featureSet.isEnabled(Feature.primary_constructors)) {
@@ -6621,7 +6624,7 @@ class _ExtensionTypeDeclarationBuilder extends _ClassLikeDeclarationBuilder {
ExtensionTypeDeclarationImpl build({
required Token typeKeyword,
required Token? constKeyword,
required _PrimaryConstructorBuilder primaryConstructorBuilder,
required _PrimaryConstructorBuilder? primaryConstructorBuilder,
required ImplementsClauseImpl? implementsClause,
}) {
ClassBodyImpl body;
@@ -6635,9 +6638,9 @@ class _ExtensionTypeDeclarationBuilder extends _ClassLikeDeclarationBuilder {
);
}
var primaryConstructor = primaryConstructorBuilder.build(
var namePart = buildClassNamePart(
typeName: name,
typeParameters: typeParameters,
primaryConstructorBuilder: primaryConstructorBuilder,
);
return ExtensionTypeDeclarationImpl(
@@ -6646,7 +6649,7 @@ class _ExtensionTypeDeclarationBuilder extends _ClassLikeDeclarationBuilder {
augmentKeyword: augmentKeyword,
extensionKeyword: extensionKeyword,
typeKeyword: typeKeyword,
primaryConstructor: primaryConstructor,
namePart: namePart,
implementsClause: implementsClause,
body: body,
);
@@ -185,6 +185,8 @@ class ConstructorItem extends ExecutableItem<ConstructorElementImpl> {
flags.isConst == element.isConst &&
flags.isFactory == element.isFactory &&
flags.isOriginDeclaration == element.isOriginDeclaration &&
flags.isOriginExtensionTypeRecovery ==
element.isOriginExtensionTypeRecovery &&
flags.isOriginImplicitDefault == element.isOriginImplicitDefault &&
flags.isOriginMixinApplication == element.isOriginMixinApplication &&
flags.isPrimary == element.isPrimary &&
@@ -1649,6 +1651,7 @@ enum _ConstructorItemFlag {
isConst,
isFactory,
isOriginDeclaration,
isOriginExtensionTypeRecovery,
isOriginImplicitDefault,
isOriginMixinApplication,
isPrimary,
@@ -1815,6 +1818,9 @@ extension type _ConstructorItemFlags._(int _bits)
if (element.isOriginDeclaration) {
bits |= _maskFor(_ConstructorItemFlag.isOriginDeclaration);
}
if (element.isOriginExtensionTypeRecovery) {
bits |= _maskFor(_ConstructorItemFlag.isOriginExtensionTypeRecovery);
}
if (element.isOriginImplicitDefault) {
bits |= _maskFor(_ConstructorItemFlag.isOriginImplicitDefault);
}
@@ -1843,6 +1849,10 @@ extension type _ConstructorItemFlags._(int _bits)
return _has(_ConstructorItemFlag.isOriginDeclaration);
}
bool get isOriginExtensionTypeRecovery {
return _has(_ConstructorItemFlag.isOriginExtensionTypeRecovery);
}
bool get isOriginImplicitDefault {
return _has(_ConstructorItemFlag.isOriginImplicitDefault);
}
@@ -965,14 +965,14 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
_checkForAugmentationTypeParameters(
fragment: declaredFragment,
firstTypeParameters: firstFragment.typeParameters,
nameOrKeywordToken: node.primaryConstructor.typeName,
typeParameterList: node.primaryConstructor.typeParameters,
nameOrKeywordToken: node.namePart.typeName,
typeParameterList: node.namePart.typeParameters,
);
_enclosingClass = firstFragment.asElement2;
_checkForBuiltInIdentifierAsName(
node.primaryConstructor.typeName,
node.namePart.typeName,
diag.builtInIdentifierAsExtensionTypeName,
);
_checkForConflictingExtensionTypeTypeVariableErrorCodes(declaredFragment);
@@ -990,13 +990,13 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
_checkForConflictingClassMembers(declaredFragment);
_checkForConflictingGenerics(
node: node,
nameToken: node.primaryConstructor.typeName,
nameToken: node.namePart.typeName,
);
libraryContext.constructorFieldsVerifier.addConstructors(
diagnosticReporter,
declaredElement,
members,
node.primaryConstructor,
node.namePart,
);
_checkForNonCovariantTypeParameterPositionInRepresentationType(
@@ -4291,7 +4291,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
) {
if (fragment.element.hasImplementsSelfReference) {
diagnosticReporter.report(
diag.extensionTypeImplementsItself.at(node.primaryConstructor.typeName),
diag.extensionTypeImplementsItself.at(node.namePart.typeName),
);
}
}
@@ -4315,11 +4315,11 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
diagnosticReporter.report(
diag.extensionTypeInheritedMemberConflict
.withArguments(
extensionTypeName: node.primaryConstructor.typeName.lexeme,
extensionTypeName: node.namePart.typeName.lexeme,
memberName: memberName,
)
.withContextMessages(contextMessages)
.at(node.primaryConstructor.typeName),
.at(node.namePart.typeName),
);
}
@@ -4346,7 +4346,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
if (fragment.element.hasRepresentationSelfReference) {
diagnosticReporter.report(
diag.extensionTypeRepresentationDependsOnItself.at(
node.primaryConstructor.typeName,
node.namePart.typeName,
),
);
}
@@ -4355,7 +4355,12 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
void _checkForExtensionTypeRepresentationErrorCodes(
ExtensionTypeDeclarationImpl node,
) {
var formalParameterList = node.primaryConstructor.formalParameters;
var primaryConstructor = node.namePart;
if (primaryConstructor is! PrimaryConstructorDeclarationImpl) {
return;
}
var formalParameterList = primaryConstructor.formalParameters;
var formalParameters = formalParameterList.parameters;
if (formalParameters.isEmpty) {
@@ -4397,7 +4402,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
return;
}
if (nameToken.lexeme == node.primaryConstructor.typeName.lexeme) {
if (nameToken.lexeme == primaryConstructor.typeName.lexeme) {
diagnosticReporter.report(diag.memberWithClassName.at(nameToken));
}
@@ -4490,7 +4495,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
diag.extensionTypeWithAbstractMember
.withArguments(
methodName: member.name.lexeme,
extensionTypeName: node.primaryConstructor.typeName.lexeme,
extensionTypeName: node.namePart.typeName.lexeme,
)
.at(member),
);
@@ -5909,7 +5914,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
ExtensionTypeDeclaration node,
ExtensionTypeFragmentImpl fragment,
) {
var typeParameters = node.primaryConstructor.typeParameters?.typeParameters;
var typeParameters = node.namePart.typeParameters?.typeParameters;
if (typeParameters == null) {
return;
}
@@ -55,7 +55,7 @@ class DefaultTypesBuilder {
_computeBounds(element, node.typeParameters);
} else if (node is ExtensionTypeDeclarationImpl) {
var element = node.declaredFragment!.element;
var typeParameters = node.primaryConstructor.typeParameters;
var typeParameters = node.namePart.typeParameters;
_breakSelfCycles(typeParameters);
_breakRawTypeCycles(element, typeParameters);
_computeBounds(element, typeParameters);
@@ -101,7 +101,7 @@ class DefaultTypesBuilder {
} else if (node is ExtensionDeclarationImpl) {
_build(node.typeParameters);
} else if (node is ExtensionTypeDeclarationImpl) {
_build(node.primaryConstructor.typeParameters);
_build(node.namePart.typeParameters);
} else if (node is FunctionTypeAliasImpl) {
_build(node.typeParameters);
} else if (node is GenericTypeAliasImpl) {
@@ -30,10 +30,52 @@ class ElementBuilder {
required Map<FragmentImpl, List<FragmentImpl>> parentChildFragments,
}) {
_buildTopFragments(topFragments);
_addExtensionTypeRecoveryFragments(parentChildFragments);
_buildInstanceElementMembers(parentChildFragments);
_buildFormalParameterElements();
}
/// Ensures that every extension type has the representation field and primary
/// constructor fragments expected by element model.
///
/// Augmentations and invalid declarations can reach this point without those
/// fragments, so this synthesizes recovery fragments before member elements
/// are built.
void _addExtensionTypeRecoveryFragments(
Map<FragmentImpl, List<FragmentImpl>> parentChildFragments,
) {
for (var extensionType in libraryElement.extensionTypes) {
var firstFragment = extensionType.firstFragment;
var childFragments = parentChildFragments[firstFragment] ??= [];
var hasPrimaryConstructor = childFragments.any(
(fragment) => fragment is ConstructorFragmentImpl && fragment.isPrimary,
);
if (!hasPrimaryConstructor) {
void prependChild(FragmentImpl child) {
child.enclosingFragment = firstFragment;
childFragments.insert(0, child);
}
prependChild(
ConstructorFragmentImpl(name: 'new')
..isPrimary = true
..isConst = true
..isOriginExtensionTypeRecovery = true
..typeName = extensionType.name,
);
prependChild(
FieldFragmentImpl(name: null)
..isFinal = true
..isOriginExtensionTypeRecoveryRepresentation = true
..hasImplicitType = true,
);
}
}
}
/// Builds elements for formal parameter fragment chains.
///
/// This runs after fragment chains are formed for constructors, methods,
@@ -53,21 +95,19 @@ class ElementBuilder {
void _buildInstanceElementMembers(
Map<FragmentImpl, List<FragmentImpl>> parentChildFragments,
) {
var elementChildFragments =
Map<InstanceElementImpl, List<FragmentImpl>>.identity();
for (var entry in parentChildFragments.entries) {
var element = entry.key.element;
if (element is InstanceElementImpl) {
(elementChildFragments[element] ??= []).addAll(entry.value);
for (var instanceElement in libraryElement.children) {
if (instanceElement is! InstanceElementImpl) {
continue;
}
}
for (var instanceEntry in elementChildFragments.entries) {
var instanceElement = instanceEntry.key;
var childFragments = [
for (var instanceFragment in instanceElement.fragments)
...?parentChildFragments[instanceFragment],
];
var lastInstanceFragments = <String?, FragmentImpl>{};
var lastStaticFragments = <String?, FragmentImpl>{};
for (var fragment in instanceEntry.value) {
for (var fragment in childFragments) {
var isInStaticNamespace = switch (fragment) {
ConstructorFragmentImpl() => true,
FieldFragmentImpl(:var isStatic) => isStatic,
@@ -1595,7 +1635,7 @@ class FragmentBuilder extends ThrowingAstVisitor<void> {
void visitExtensionTypeDeclaration(
covariant ExtensionTypeDeclarationImpl node,
) {
var nameToken = node.primaryConstructor.typeName;
var nameToken = node.namePart.typeName;
var fragmentName = _getFragmentName(nameToken);
var fragment = ExtensionTypeFragmentImpl(name: fragmentName);
@@ -1609,7 +1649,7 @@ class FragmentBuilder extends ThrowingAstVisitor<void> {
var holder = _EnclosingContext(fragment: fragment);
_withEnclosing(holder, () {
node.primaryConstructor.accept(this);
node.namePart.accept(this);
node.body.accept(this);
});
@@ -146,7 +146,6 @@ class InformativeDataApplier {
);
}
/// This calls `withOriginDeclaration` on [fragmentList].
void _applyToAccessors(
List<PropertyAccessorFragmentImpl> fragmentList,
List<_InfoExecutableDeclaration> infoList,
@@ -244,7 +243,10 @@ class InformativeDataApplier {
List<ConstructorFragmentImpl> fragmentList,
List<_InfoConstructorDeclaration> infoList,
) {
forCorrespondingPairs(fragmentList, infoList, (fragment, info) {
forCorrespondingPairs(fragmentList.withOriginDeclaration, infoList, (
fragment,
info,
) {
fragment.setCodeRange(info.codeOffset, info.codeLength);
fragment.newKeywordOffset = info.newKeywordOffset;
fragment.factoryKeywordOffset = info.factoryKeywordOffset;
@@ -842,9 +844,9 @@ class _InfoBuilder {
return _InfoExtensionTypeDeclaration(
data: _buildInterfaceData(
node,
name: node.primaryConstructor.typeName,
typeParameters: node.primaryConstructor.typeParameters,
primaryConstructor: node.primaryConstructor,
name: node.namePart.typeName,
typeParameters: node.namePart.typeParameters,
primaryConstructor: node.namePart.tryCast(),
members: node.body.members,
),
);
@@ -2294,6 +2296,12 @@ extension on DeferredResolutionReadingMixin {
}
}
extension on List<ConstructorFragmentImpl> {
Iterable<ConstructorFragmentImpl> get withOriginDeclaration {
return where((e) => e.isOriginDeclaration);
}
}
extension _ListOfPropertyAccessorFragment<
T extends PropertyAccessorFragmentImpl
>
@@ -139,11 +139,14 @@ class MetadataResolver extends ThrowingAstVisitor<void> {
covariant ExtensionTypeDeclarationImpl node,
) {
node.metadata.accept(this);
node.primaryConstructor.typeParameters?.accept(this);
node.namePart.typeParameters?.accept(this);
_scope = node.bodyScope!;
try {
node.primaryConstructor.formalParameters.accept(this);
node.namePart
.tryCast<PrimaryConstructorDeclaration>()
?.formalParameters
.accept(this);
node.body.accept(this);
} finally {
_scope = _containerScope;
@@ -120,7 +120,7 @@ class SimplyBoundedDependencyWalker
const <TypeAnnotation>[],
);
} else if (node is ExtensionTypeDeclaration) {
var parameters = node.primaryConstructor.typeParameters?.typeParameters;
var parameters = node.namePart.typeParameters?.typeParameters;
graphNode = SimplyBoundedNode(
this,
node,
@@ -250,7 +250,7 @@ extension type E(int i) {}
checkOffset<ExtensionTypeFragment>(
extensionTypeDeclaration,
extensionTypeDeclaration.declaredFragment!,
extensionTypeDeclaration.primaryConstructor.typeName.offset,
extensionTypeDeclaration.namePart.typeName.offset,
);
}
@@ -16,7 +16,32 @@ main() {
@reflectiveTest
class ExtensionTypeDeclarationParserTest extends ParserDiagnosticsTest {
test_augment() {
test_augment_implementsClause() {
var parseResult = parseTestCodeWithDiagnostics(r'''
augment extension type E implements I {}
''');
assertParsedNodeText(
parseResult.findNode.singleExtensionTypeDeclaration,
r'''
ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
namePart: NameWithTypeParameters
typeName: E
implementsClause: ImplementsClause
implementsKeyword: implements
interfaces
NamedType
name: I
body: BlockClassBody
leftBracket: {
rightBracket: }
''',
);
}
test_augment_primaryConstructor() {
var parseResult = parseTestCodeWithDiagnostics(r'''
augment extension type A(int it) {}
// ^
@@ -29,7 +54,7 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -44,40 +69,6 @@ ExtensionTypeDeclaration
''');
}
test_augment_implementsClause() {
var parseResult = parseTestCodeWithDiagnostics(r'''
augment extension type E(int it) implements I {}
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
''');
assertParsedNodeText(
parseResult.findNode.singleExtensionTypeDeclaration,
r'''
ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
typeName: E
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
name: it
rightParenthesis: )
implementsClause: ImplementsClause
implementsKeyword: implements
interfaces
NamedType
name: I
body: BlockClassBody
leftBracket: {
rightBracket: }
''',
);
}
test_body_empty() {
var parseResult = parseTestCodeWithDiagnostics(r'''
extension type A(int it);
@@ -88,7 +79,7 @@ extension type A(int it);
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -470,7 +461,7 @@ extension type A(int it) {
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -516,7 +507,7 @@ extension type A(int it) {
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -592,7 +583,7 @@ extension type A(int it) {
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -624,9 +615,7 @@ ExtensionTypeDeclaration
test_members_constructor_augment() {
var parseResult = parseTestCodeWithDiagnostics(r'''
augment extension type E(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type E {
augment E.named();
}
''');
@@ -637,15 +626,8 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: NameWithTypeParameters
typeName: E
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
name: it
rightParenthesis: )
body: BlockClassBody
leftBracket: {
members
@@ -667,9 +649,7 @@ ExtensionTypeDeclaration
test_members_constructor_augment_factory_unnamed() {
var parseResult = parseTestCodeWithDiagnostics(r'''
augment extension type E(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type E {
augment factory E() => E(0);
}
''');
@@ -701,9 +681,7 @@ ConstructorDeclaration
test_members_field_augment() {
var parseResult = parseTestCodeWithDiagnostics(r'''
augment extension type E(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type E {
augment int foo = 0;
}
''');
@@ -714,15 +692,8 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: NameWithTypeParameters
typeName: E
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
name: it
rightParenthesis: )
body: BlockClassBody
leftBracket: {
members
@@ -745,9 +716,7 @@ ExtensionTypeDeclaration
test_members_field_augment_static() {
var parseResult = parseTestCodeWithDiagnostics(r'''
augment extension type E(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type E {
augment static int foo = 0;
}
''');
@@ -758,15 +727,8 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: NameWithTypeParameters
typeName: E
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
name: it
rightParenthesis: )
body: BlockClassBody
leftBracket: {
members
@@ -800,7 +762,7 @@ extension type A(int it) {
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -840,7 +802,7 @@ extension type A(int it) {
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -880,7 +842,7 @@ extension type A(int it) {
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -908,9 +870,7 @@ ExtensionTypeDeclaration
test_members_getter_augment() {
var parseResult = parseTestCodeWithDiagnostics(r'''
augment extension type E(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type E {
augment int get foo => 0;
}
''');
@@ -921,15 +881,8 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: NameWithTypeParameters
typeName: E
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
name: it
rightParenthesis: )
body: BlockClassBody
leftBracket: {
members
@@ -951,9 +904,7 @@ ExtensionTypeDeclaration
test_members_getter_augment_static() {
var parseResult = parseTestCodeWithDiagnostics(r'''
augment extension type E(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type E {
augment static int get foo => 0;
}
''');
@@ -964,15 +915,8 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: NameWithTypeParameters
typeName: E
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
name: it
rightParenthesis: )
body: BlockClassBody
leftBracket: {
members
@@ -1005,7 +949,7 @@ extension type A(int it) {
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1034,9 +978,7 @@ ExtensionTypeDeclaration
test_members_method_augment() {
var parseResult = parseTestCodeWithDiagnostics(r'''
augment extension type E(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type E {
augment void foo() {}
}
''');
@@ -1047,15 +989,8 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: NameWithTypeParameters
typeName: E
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
name: it
rightParenthesis: )
body: BlockClassBody
leftBracket: {
members
@@ -1078,9 +1013,7 @@ ExtensionTypeDeclaration
test_members_method_augment_static() {
var parseResult = parseTestCodeWithDiagnostics(r'''
augment extension type E(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type E {
augment static void foo() {}
}
''');
@@ -1091,15 +1024,8 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: NameWithTypeParameters
typeName: E
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
name: it
rightParenthesis: )
body: BlockClassBody
leftBracket: {
members
@@ -1123,9 +1049,7 @@ ExtensionTypeDeclaration
test_members_operator_augment() {
var parseResult = parseTestCodeWithDiagnostics(r'''
augment extension type E(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type E {
augment int operator+(int other) => 0;
}
''');
@@ -1136,15 +1060,8 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: NameWithTypeParameters
typeName: E
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
name: it
rightParenthesis: )
body: BlockClassBody
leftBracket: {
members
@@ -1183,7 +1100,7 @@ extension type A(int it) {
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1215,9 +1132,7 @@ ExtensionTypeDeclaration
test_members_setter_augment() {
var parseResult = parseTestCodeWithDiagnostics(r'''
augment extension type E(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type E {
augment set foo(int x) {}
}
''');
@@ -1228,15 +1143,8 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: NameWithTypeParameters
typeName: E
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
name: it
rightParenthesis: )
body: BlockClassBody
leftBracket: {
members
@@ -1262,9 +1170,7 @@ ExtensionTypeDeclaration
test_members_setter_augment_static() {
var parseResult = parseTestCodeWithDiagnostics(r'''
augment extension type E(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type E {
augment static set foo(int x) {}
}
''');
@@ -1275,15 +1181,8 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: NameWithTypeParameters
typeName: E
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
name: it
rightParenthesis: )
body: BlockClassBody
leftBracket: {
members
@@ -1324,7 +1223,7 @@ ExtensionTypeDeclaration
token: foo
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1349,7 +1248,7 @@ extension type const A<T, U>.named(int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
constKeyword: const
typeName: A
typeParameters: TypeParameterList
@@ -1386,7 +1285,7 @@ extension type const A<T, U>(int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
constKeyword: const
typeName: A
typeParameters: TypeParameterList
@@ -1420,7 +1319,7 @@ extension type const A.named(int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
constKeyword: const
typeName: A
constructorName: PrimaryConstructorName
@@ -1449,7 +1348,7 @@ extension type const A(int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
constKeyword: const
typeName: A
formalParameters: FormalParameterList
@@ -1477,7 +1376,7 @@ extension type const E {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: E
formalParameters: FormalParameterList
leftParenthesis: ( <synthetic>
@@ -1498,7 +1397,7 @@ extension type A({int a = 0}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1529,7 +1428,7 @@ extension type A([int a = 0]) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1563,7 +1462,7 @@ extension type A(
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1603,7 +1502,7 @@ extension type A({
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1642,7 +1541,7 @@ extension type A(
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1671,7 +1570,7 @@ extension type A(this.it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1696,7 +1595,7 @@ extension type A(int it()) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1727,7 +1626,7 @@ extension type A(const int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1755,7 +1654,7 @@ extension type A(covariant int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1783,7 +1682,7 @@ extension type A(covariant final int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1813,7 +1712,7 @@ extension type A(covariant int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1839,7 +1738,7 @@ extension type A(covariant var int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1866,7 +1765,7 @@ extension type A(final int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1893,7 +1792,7 @@ extension type A(final int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1919,7 +1818,7 @@ extension type A(final it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1944,7 +1843,7 @@ extension type A(final it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1970,7 +1869,7 @@ extension type A(required int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1998,7 +1897,7 @@ extension type A(static int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2023,7 +1922,7 @@ extension type A(var it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2048,7 +1947,7 @@ extension type A(var it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2072,7 +1971,7 @@ extension type A({int it = 0}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2104,7 +2003,7 @@ extension type A({int it = 0}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2135,7 +2034,7 @@ extension type A({int? a, int? b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2169,7 +2068,7 @@ extension type A({int? a, int? b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2202,7 +2101,7 @@ extension type A({int? a, required int b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2235,7 +2134,7 @@ extension type A([int it = 0]) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2267,7 +2166,7 @@ extension type A([int it = 0]) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2298,7 +2197,7 @@ extension type A([int? a, int? b]) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2332,7 +2231,7 @@ extension type A([int? a, int? b]) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2365,7 +2264,7 @@ extension type A({required int it}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2394,7 +2293,7 @@ extension type A({required int it}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2422,7 +2321,7 @@ extension type A({required int a, int? b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2455,7 +2354,7 @@ extension type A({required int a, required int b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2488,7 +2387,7 @@ extension type A(int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2514,7 +2413,7 @@ extension type A(int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2539,7 +2438,7 @@ extension type A(int a, {int? b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2572,7 +2471,7 @@ extension type A(int a, {int? b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2604,7 +2503,7 @@ extension type A(int a, [int? b]) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2637,7 +2536,7 @@ extension type A(int a, [int? b]) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2669,7 +2568,7 @@ extension type A(int a, int b) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2699,7 +2598,7 @@ extension type A(int a, int b) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2728,7 +2627,7 @@ extension type A(int A) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2753,7 +2652,7 @@ extension type A(@foo int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2783,7 +2682,7 @@ extension type A() {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2805,7 +2704,7 @@ extension type A() {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2826,7 +2725,7 @@ extension type A(it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2850,7 +2749,7 @@ extension type A(it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2873,7 +2772,7 @@ extension type A(@foo it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2901,7 +2800,7 @@ extension type A(super.it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2926,7 +2825,7 @@ extension type A(int it,) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2952,7 +2851,7 @@ extension type A(int it,) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2979,7 +2878,7 @@ extension type E {}
ExtensionTypeDeclaration
extensionKeyword: extension @0
typeKeyword: type @10
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: E @15
formalParameters: FormalParameterList
leftParenthesis: ( @17 <synthetic>
@@ -3000,7 +2899,7 @@ extension type A<T, U>.named(int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
typeParameters: TypeParameterList
leftBracket: <
@@ -3036,7 +2935,7 @@ extension type A<T, U>(int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
typeParameters: TypeParameterList
leftBracket: <
@@ -3069,7 +2968,7 @@ extension type A.named(int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
constructorName: PrimaryConstructorName
period: .
@@ -3097,7 +2996,7 @@ extension type A(int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -3124,7 +3023,7 @@ extension type A(int it) {
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -3154,7 +3053,7 @@ extension type A(int it) implements B, C {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -3186,7 +3085,7 @@ extension type A<T>(int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
typeParameters: TypeParameterList
leftBracket: <
@@ -16,6 +16,46 @@ main() {
@reflectiveTest
class ExtensionTypeResolutionTest extends PubPackageResolutionTest {
test_augment_primaryConstructor() async {
var result = await resolveTestCodeWithDiagnostics(r'''
extension type A(int it) {}
augment extension type A(int it) {}
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
''');
var node = result.findNode.extensionTypeDeclaration('augment');
assertResolvedNodeText(node, r'''
ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
element: dart:core::@class::int
type: int
name: it
declaredFragment: <testLibraryFragment> it@58
element: isFinal isPublic
type: int
field: <testLibrary>::@extensionType::A::@field::it
rightParenthesis: )
declaredFragment: <testLibraryFragment> new@null
element: <testLibrary>::@extensionType::A::@constructor::new
type: A Function(int)
body: BlockClassBody
leftBracket: {
rightBracket: }
declaredFragment: <testLibraryFragment> A@52
''');
}
test_constructor_factoryHead_named() async {
var result = await resolveTestCodeWithDiagnostics(r'''
extension type A(int it) {
@@ -516,7 +556,7 @@ extension type A(String it) {
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -588,7 +628,7 @@ extension type A(int it) implements num {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -704,7 +744,7 @@ extension type A({int a = 0}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -746,7 +786,7 @@ extension type A([int a = 0]) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -790,7 +830,7 @@ extension type A(this.it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -826,7 +866,7 @@ extension type A(this.it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -859,7 +899,7 @@ extension type A(int it()) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -901,7 +941,7 @@ extension type A(int it()) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -942,7 +982,7 @@ extension type A(const int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -981,7 +1021,7 @@ extension type A(const int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1019,7 +1059,7 @@ extension type A(covariant int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1058,7 +1098,7 @@ extension type A(covariant int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1094,7 +1134,7 @@ extension type A(final int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1133,7 +1173,7 @@ extension type A(final int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1169,7 +1209,7 @@ extension type A(final it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1206,7 +1246,7 @@ extension type A(final it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1240,7 +1280,7 @@ extension type A(required int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1278,7 +1318,7 @@ extension type A(static int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1315,7 +1355,7 @@ extension type A(var it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1352,7 +1392,7 @@ extension type A(var it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1384,7 +1424,7 @@ extension type A({int? it}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1425,7 +1465,7 @@ extension type A({int? it}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1465,7 +1505,7 @@ extension type A({int? a, int? b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1516,7 +1556,7 @@ extension type A({int? a, int? b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1566,7 +1606,7 @@ extension type A({int? a, required int b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1614,7 +1654,7 @@ extension type A([int? it]) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1655,7 +1695,7 @@ extension type A([int? it]) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1695,7 +1735,7 @@ extension type A([int? a, int? b]) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1746,7 +1786,7 @@ extension type A([int? a, int? b]) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1794,7 +1834,7 @@ extension type A({required int it}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1835,7 +1875,7 @@ extension type A({required int it}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1875,7 +1915,7 @@ extension type A({required int a, int? b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1925,7 +1965,7 @@ extension type A({required int a, required int b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -1973,7 +2013,7 @@ extension type A(int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2009,7 +2049,7 @@ extension type A(int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2046,7 +2086,7 @@ extension type A(int a, {int? b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2096,7 +2136,7 @@ extension type A(int a, {int? b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2145,7 +2185,7 @@ extension type A(int a, {int? b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2195,7 +2235,7 @@ extension type A(int a, {int? b}) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2244,7 +2284,7 @@ extension type A(int a, int b) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2291,7 +2331,7 @@ extension type A(int a, int b) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2337,7 +2377,7 @@ extension type A(int A) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2375,7 +2415,7 @@ extension type A(int A) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2410,7 +2450,7 @@ extension type A(@deprecated int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2455,7 +2495,7 @@ extension type A() {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2483,7 +2523,7 @@ extension type A() {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2508,7 +2548,7 @@ extension type A(it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2542,7 +2582,7 @@ extension type A(it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2573,7 +2613,7 @@ extension type A(@deprecated it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2615,7 +2655,7 @@ extension type A(@deprecated it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2658,7 +2698,7 @@ extension type A(int it) {
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2714,7 +2754,7 @@ extension type A(int it) {
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2769,7 +2809,7 @@ extension type A(super.it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2804,7 +2844,7 @@ extension type A(super.it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2836,7 +2876,7 @@ extension type A(int it,) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2874,7 +2914,7 @@ extension type A(int it,) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -2913,7 +2953,7 @@ extension type E {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: E
formalParameters: FormalParameterList
leftParenthesis: ( <synthetic>
@@ -2938,7 +2978,7 @@ extension type A.named(int it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
constructorName: PrimaryConstructorName
period: .
@@ -3098,7 +3138,7 @@ extension type A({bool it = false}) {
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -3305,7 +3345,7 @@ extension type A(int it) {
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -3366,7 +3406,7 @@ extension type A(num it) {
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
@@ -3455,7 +3495,7 @@ extension type A<T, U>(Map<T, U> it) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: A
typeParameters: TypeParameterList
leftBracket: <
@@ -3514,7 +3554,7 @@ extension type ET<_, _, _ extends num>(int _) {}
ExtensionTypeDeclaration
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: PrimaryConstructorDeclaration
typeName: ET
typeParameters: TypeParameterList
leftBracket: <
@@ -489,10 +489,8 @@ augment extension A {}
class A {}
// ^
// [context 1] The declaration being augmented.
augment extension type A(int it) {}
augment extension type A {}
// [diag.augmentationOfDifferentDeclarationKind][column 1][length 7][context 1] Can't augment a class with a extension type.
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
''');
}
@@ -171,9 +171,7 @@ extension type A(int it) {
int get foo => 0;
}
augment extension type A(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type A {
augment String get foo;
// ^^^^^^
// [diag.augmentationReturnTypeMismatch] The augmentation's return type 'String' must be the same as the introductory declaration's return type 'int'.
@@ -187,9 +185,7 @@ extension type A(int it) {
void foo() {}
}
augment extension type A(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type A {
augment int foo();
// ^^^
// [diag.augmentationReturnTypeMismatch] The augmentation's return type 'int' must be the same as the introductory declaration's return type 'void'.
@@ -174,40 +174,32 @@ augment extension A<T extends num> {}
test_extensionType_nothing_num() async {
await resolveTestCodeWithDiagnostics(r'''
extension type A<T>(int it) {}
augment extension type A<T extends num>(int it) {}
augment extension type A<T extends num> {}
// ^^^
// [diag.augmentationTypeParameterBound] The augmentation type parameter must have the same bound as the corresponding type parameter of the declaration.
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
''');
}
test_extensionType_num_int() async {
await resolveTestCodeWithDiagnostics(r'''
extension type A<T extends num>(int it) {}
augment extension type A<T extends int>(int it) {}
augment extension type A<T extends int> {}
// ^^^
// [diag.augmentationTypeParameterBound] The augmentation type parameter must have the same bound as the corresponding type parameter of the declaration.
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
''');
}
test_extensionType_num_nothing() async {
await resolveTestCodeWithDiagnostics(r'''
extension type A<T extends num>(int it) {}
augment extension type A<T>(int it) {}
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type A<T> {}
''');
}
test_extensionType_num_num() async {
await resolveTestCodeWithDiagnostics(r'''
extension type A<T extends num>(int it) {}
augment extension type A<T extends num>(int it) {}
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type A<T extends num> {}
''');
}
@@ -587,11 +587,9 @@ ExtensionDeclaration
test_extensionType_0_1() async {
var result = await resolveTestCodeWithDiagnostics(r'''
extension type A(int it) {}
augment extension type A<T>(int it) {}
augment extension type A<T> {}
// ^
// [diag.augmentationTypeParameterCount] The augmentation must have the same number of type parameters as the declaration.
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
''');
var node = result.findNode.extensionTypeDeclaration(
'augment extension type A',
@@ -601,7 +599,7 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: NameWithTypeParameters
typeName: A
typeParameters: TypeParameterList
leftBracket: <
@@ -611,22 +609,6 @@ ExtensionTypeDeclaration
declaredFragment: <testLibraryFragment> T@53
defaultType: dynamic
rightBracket: >
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
element: dart:core::@class::int
type: int
name: it
declaredFragment: <testLibraryFragment> it@60
element: isFinal isPublic
type: int
field: <testLibrary>::@extensionType::A::@field::it
rightParenthesis: )
declaredFragment: <testLibraryFragment> new@null
element: <testLibrary>::@extensionType::A::@constructor::new
type: A<T> Function(int)
body: BlockClassBody
leftBracket: {
rightBracket: }
@@ -637,11 +619,9 @@ ExtensionTypeDeclaration
test_extensionType_1_0() async {
var result = await resolveTestCodeWithDiagnostics(r'''
extension type A<T>(int it) {}
augment extension type A(int it) {}
augment extension type A {}
// ^
// [diag.augmentationTypeParameterCount] The augmentation must have the same number of type parameters as the declaration.
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
''');
var node = result.findNode.extensionTypeDeclaration(
'augment extension type A',
@@ -651,24 +631,8 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: NameWithTypeParameters
typeName: A
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
element: dart:core::@class::int
type: int
name: it
declaredFragment: <testLibraryFragment> it@60
element: isFinal isPublic
type: int
field: <testLibrary>::@extensionType::A::@field::it
rightParenthesis: )
declaredFragment: <testLibraryFragment> new@null
element: <testLibrary>::@extensionType::A::@constructor::new
type: A<T> Function(int)
body: BlockClassBody
leftBracket: {
rightBracket: }
@@ -679,9 +643,7 @@ ExtensionTypeDeclaration
test_extensionType_1_1() async {
var result = await resolveTestCodeWithDiagnostics(r'''
extension type A<T>(int it) {}
augment extension type A<T>(int it) {}
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type A<T> {}
''');
var node = result.findNode.extensionTypeDeclaration(
'augment extension type A',
@@ -691,7 +653,7 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: NameWithTypeParameters
typeName: A
typeParameters: TypeParameterList
leftBracket: <
@@ -701,22 +663,6 @@ ExtensionTypeDeclaration
declaredFragment: <testLibraryFragment> T@56
defaultType: dynamic
rightBracket: >
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
element: dart:core::@class::int
type: int
name: it
declaredFragment: <testLibraryFragment> it@63
element: isFinal isPublic
type: int
field: <testLibrary>::@extensionType::A::@field::it
rightParenthesis: )
declaredFragment: <testLibraryFragment> new@null
element: <testLibrary>::@extensionType::A::@constructor::new
type: A<T> Function(int)
body: BlockClassBody
leftBracket: {
rightBracket: }
@@ -727,11 +673,9 @@ ExtensionTypeDeclaration
test_extensionType_1_2() async {
var result = await resolveTestCodeWithDiagnostics(r'''
extension type A<T>(int it) {}
augment extension type A<T, U>(int it) {}
augment extension type A<T, U> {}
// ^
// [diag.augmentationTypeParameterCount] The augmentation must have the same number of type parameters as the declaration.
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
''');
var node = result.findNode.extensionTypeDeclaration(
'augment extension type A',
@@ -741,7 +685,7 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: NameWithTypeParameters
typeName: A
typeParameters: TypeParameterList
leftBracket: <
@@ -755,22 +699,6 @@ ExtensionTypeDeclaration
declaredFragment: <testLibraryFragment> U@59
defaultType: dynamic
rightBracket: >
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
element: dart:core::@class::int
type: int
name: it
declaredFragment: <testLibraryFragment> it@66
element: isFinal isPublic
type: int
field: <testLibrary>::@extensionType::A::@field::it
rightParenthesis: )
declaredFragment: <testLibraryFragment> new@null
element: <testLibrary>::@extensionType::A::@constructor::new
type: A<T, U> Function(int)
body: BlockClassBody
leftBracket: {
rightBracket: }
@@ -781,11 +709,9 @@ ExtensionTypeDeclaration
test_extensionType_2_1() async {
var result = await resolveTestCodeWithDiagnostics(r'''
extension type A<T, U>(int it) {}
augment extension type A<T>(int it) {}
augment extension type A<T> {}
// ^
// [diag.augmentationTypeParameterCount] The augmentation must have the same number of type parameters as the declaration.
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
''');
var node = result.findNode.extensionTypeDeclaration(
'augment extension type A',
@@ -795,7 +721,7 @@ ExtensionTypeDeclaration
augmentKeyword: augment
extensionKeyword: extension
typeKeyword: type
primaryConstructor: PrimaryConstructorDeclaration
namePart: NameWithTypeParameters
typeName: A
typeParameters: TypeParameterList
leftBracket: <
@@ -805,22 +731,6 @@ ExtensionTypeDeclaration
declaredFragment: <testLibraryFragment> T@59
defaultType: dynamic
rightBracket: >
formalParameters: FormalParameterList
leftParenthesis: (
parameter: RegularFormalParameter
type: NamedType
name: int
element: dart:core::@class::int
type: int
name: it
declaredFragment: <testLibraryFragment> it@66
element: isFinal isPublic
type: int
field: <testLibrary>::@extensionType::A::@field::it
rightParenthesis: )
declaredFragment: <testLibraryFragment> new@null
element: <testLibrary>::@extensionType::A::@constructor::new
type: A<T, U> Function(int)
body: BlockClassBody
leftBracket: {
rightBracket: }
@@ -68,11 +68,9 @@ augment extension A<U> {}
test_extensionType_T_U() async {
await resolveTestCodeWithDiagnostics(r'''
extension type A<T>(int it) {}
augment extension type A<U>(int it) {}
augment extension type A<U> {}
// ^
// [diag.augmentationTypeParameterName] The augmentation type parameter must have the same name as the corresponding type parameter of the declaration.
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
''');
}
@@ -1008,10 +1008,8 @@ augment extension A {
test_extensionType() async {
await resolveTestCodeWithDiagnostics(r'''
augment extension type A(int it) {}
augment extension type A {}
// [diag.augmentationWithoutDeclaration][column 1][length 7] The declaration being augmented doesn't exist.
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
''');
}
@@ -1019,9 +1017,7 @@ augment extension type A(int it) {}
await resolveTestCodeWithDiagnostics(r'''
extension type A(int it) {}
augment extension type A(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type A {
augment A.named() : this(0);
//^^^^^^^
// [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist.
@@ -1029,13 +1025,20 @@ augment extension type A(int it) {
''');
}
test_extensionType_hasPrimaryConstructor() async {
await resolveTestCodeWithDiagnostics(r'''
augment extension type A(int it) {}
// [diag.augmentationWithoutDeclaration][column 1][length 7] The declaration being augmented doesn't exist.
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
''');
}
test_extensionType_instanceGetter() async {
await resolveTestCodeWithDiagnostics(r'''
extension type A(int it) {}
augment extension type A(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type A {
augment int get foo => 0;
//^^^^^^^
// [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist.
@@ -1047,9 +1050,7 @@ augment extension type A(int it) {
await resolveTestCodeWithDiagnostics(r'''
extension type A(int it) {}
augment extension type A(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type A {
augment void foo() {}
//^^^^^^^
// [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist.
@@ -1061,9 +1062,7 @@ augment extension type A(int it) {
await resolveTestCodeWithDiagnostics(r'''
extension type A(int it) {}
augment extension type A(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type A {
augment set foo(int _) {}
//^^^^^^^
// [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist.
@@ -2253,9 +2253,7 @@ extension type E(int it) {
// [context 1] The corresponding getter is declared here.
}
augment extension type E(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type E {
augment int foo = 0;
// ^^^
// [diag.augmentationWithoutSetterDeclaration][context 1] This augmentation induces a setter, but no setter declaration named 'foo' exists to augment.
@@ -2378,9 +2376,7 @@ extension type E(int it) {
// [context 1] The corresponding setter is declared here.
}
augment extension type E(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type E {
augment int foo = 0;
// ^^^
// [diag.augmentationWithoutGetterDeclaration][context 1] This augmentation induces a getter, but no getter declaration named 'foo' exists to augment.
@@ -2493,9 +2489,7 @@ extension type E(int it) {
// [context 1] The corresponding getter is declared here.
}
augment extension type E(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type E {
augment static int foo = 0;
// ^^^
// [diag.augmentationWithoutSetterDeclaration][context 1] This augmentation induces a setter, but no setter declaration named 'foo' exists to augment.
@@ -2585,9 +2579,7 @@ extension type E(int it) {
// [context 1] The corresponding setter is declared here.
}
augment extension type E(int it) {
// ^
// [diag.extensionTypeAugmentationSpecifiesRepresentationField] An extension type augmentation can't specify a representation field.
augment extension type E {
augment static int foo = 0;
// ^^^
// [diag.augmentationWithoutGetterDeclaration][context 1] This augmentation induces a getter, but no getter declaration named 'foo' exists to augment.
@@ -221,7 +221,7 @@ extension type A(int it) implements int {}
var b = newFile('$testPackageLibPath/b.dart', r'''
part of 'a.dart';
augment extension type A(int it) implements int {}
augment extension type A implements int {}
''');
await assertErrorsInFile2(a, []);
@@ -352,6 +352,7 @@ class _Element2Writer extends _AbstractElementWriter {
_sink.writeHeaderFlags(e.flagsForTesting);
_assertHasExactlyOneTrue([
e.isOriginDeclaration,
e.isOriginExtensionTypeRecovery,
e.isOriginImplicitDefault,
e.isOriginMixinApplication,
]);
@@ -413,6 +414,7 @@ class _Element2Writer extends _AbstractElementWriter {
_sink.writeHeaderFlags(f.flagsForTesting);
_assertHasExactlyOneTrue([
f.isOriginDeclaration,
f.isOriginExtensionTypeRecovery,
f.isOriginImplicitDefault,
f.isOriginMixinApplication,
]);
@@ -6692,6 +6692,249 @@ library
test_extensionType_augmentation_chain_noIntroductoryDeclaration() async {
var library = await buildLibrary(r'''
augment extension type A {
void foo1() {}
}
augment extension type A {
void foo2() {}
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
fragments
#F0 <testLibraryFragment>
element: <testLibrary>
extensionTypes
#F1 isAugmentation extension type A (nameOffset:23) (firstTokenOffset:0) (offset:23)
element: <testLibrary>::@extensionType::A
nextFragment: #F2
fields
#F3 hasImplicitType isFinal isOriginExtensionTypeRecoveryRepresentation <null-name> (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@field::#0
inducedGetter: #F4
constructors
#F5 isConst isOriginExtensionTypeRecovery isPrimary new (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@constructor::new
typeName: A
getters
#F4 isCompleteDeclaration isOriginVariable <null-name> (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@getter::#1
inducingVariable: #F3
methods
#F6 isCompleteDeclaration isOriginDeclaration foo1 (nameOffset:34) (firstTokenOffset:29) (offset:34)
element: <testLibrary>::@extensionType::A::@method::foo1
#F2 isAugmentation extension type A (nameOffset:70) (firstTokenOffset:47) (offset:70)
element: <testLibrary>::@extensionType::A
previousFragment: #F1
methods
#F7 isCompleteDeclaration isOriginDeclaration foo2 (nameOffset:81) (firstTokenOffset:76) (offset:81)
element: <testLibrary>::@extensionType::A::@method::foo2
extensionTypes
isSimplyBounded extension type A
reference: <testLibrary>::@extensionType::A
firstFragment: #F1
representation: <testLibrary>::@extensionType::A::@field::#0
primaryConstructor: <testLibrary>::@extensionType::A::@constructor::new
typeErasure: dynamic
fields
hasImplicitType isFinal isOriginExtensionTypeRecoveryRepresentation <null-name>
reference: <testLibrary>::@extensionType::A::@field::#0
firstFragment: #F3
type: dynamic
getter: <testLibrary>::@extensionType::A::@getter::#1
constructors
isConst isExtensionTypeMember isOriginExtensionTypeRecovery isPrimary new
reference: <testLibrary>::@extensionType::A::@constructor::new
firstFragment: #F5
getters
isExtensionTypeMember isOriginVariable <null-name>
reference: <testLibrary>::@extensionType::A::@getter::#1
firstFragment: #F4
returnType: dynamic
variable: <testLibrary>::@extensionType::A::@field::#0
methods
isExtensionTypeMember isOriginDeclaration foo1
reference: <testLibrary>::@extensionType::A::@method::foo1
firstFragment: #F6
returnType: void
isExtensionTypeMember isOriginDeclaration foo2
reference: <testLibrary>::@extensionType::A::@method::foo2
firstFragment: #F7
returnType: void
''');
}
test_extensionType_augmentation_chain_noIntroductoryDeclaration_emptyThenSecondaryConstructor() async {
var library = await buildLibrary(r'''
augment extension type A {}
augment extension type A {
A.named();
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
fragments
#F0 <testLibraryFragment>
element: <testLibrary>
extensionTypes
#F1 isAugmentation extension type A (nameOffset:23) (firstTokenOffset:0) (offset:23)
element: <testLibrary>::@extensionType::A
nextFragment: #F2
fields
#F3 hasImplicitType isFinal isOriginExtensionTypeRecoveryRepresentation <null-name> (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@field::#0
inducedGetter: #F4
constructors
#F5 isConst isOriginExtensionTypeRecovery isPrimary new (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@constructor::new
typeName: A
getters
#F4 isCompleteDeclaration isOriginVariable <null-name> (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@getter::#1
inducingVariable: #F3
#F2 isAugmentation extension type A (nameOffset:52) (firstTokenOffset:29) (offset:52)
element: <testLibrary>::@extensionType::A
previousFragment: #F1
constructors
#F6 isOriginDeclaration named (nameOffset:60) (firstTokenOffset:58) (offset:60)
element: <testLibrary>::@extensionType::A::@constructor::named
typeName: A
typeNameOffset: 58
periodOffset: 59
extensionTypes
isSimplyBounded extension type A
reference: <testLibrary>::@extensionType::A
firstFragment: #F1
representation: <testLibrary>::@extensionType::A::@field::#0
primaryConstructor: <testLibrary>::@extensionType::A::@constructor::new
typeErasure: dynamic
fields
hasImplicitType isFinal isOriginExtensionTypeRecoveryRepresentation <null-name>
reference: <testLibrary>::@extensionType::A::@field::#0
firstFragment: #F3
type: dynamic
getter: <testLibrary>::@extensionType::A::@getter::#1
constructors
isConst isExtensionTypeMember isOriginExtensionTypeRecovery isPrimary new
reference: <testLibrary>::@extensionType::A::@constructor::new
firstFragment: #F5
isExtensionTypeMember isOriginDeclaration named
reference: <testLibrary>::@extensionType::A::@constructor::named
firstFragment: #F6
getters
isExtensionTypeMember isOriginVariable <null-name>
reference: <testLibrary>::@extensionType::A::@getter::#1
firstFragment: #F4
returnType: dynamic
variable: <testLibrary>::@extensionType::A::@field::#0
''');
}
test_extensionType_augmentation_chain_noIntroductoryDeclaration_emptyThenStaticField() async {
var library = await buildLibrary(r'''
augment extension type A {}
augment extension type A {
static int foo = 0;
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
fragments
#F0 <testLibraryFragment>
element: <testLibrary>
extensionTypes
#F1 isAugmentation extension type A (nameOffset:23) (firstTokenOffset:0) (offset:23)
element: <testLibrary>::@extensionType::A
nextFragment: #F2
fields
#F3 hasImplicitType isFinal isOriginExtensionTypeRecoveryRepresentation <null-name> (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@field::#0
inducedGetter: #F4
constructors
#F5 isConst isOriginExtensionTypeRecovery isPrimary new (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@constructor::new
typeName: A
getters
#F4 isCompleteDeclaration isOriginVariable <null-name> (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@getter::#1
inducingVariable: #F3
#F2 isAugmentation extension type A (nameOffset:52) (firstTokenOffset:29) (offset:52)
element: <testLibrary>::@extensionType::A
previousFragment: #F1
fields
#F6 hasInitializer isOriginDeclaration isStatic foo (nameOffset:69) (firstTokenOffset:69) (offset:69)
element: <testLibrary>::@extensionType::A::@field::foo
inducedGetter: #F7
inducedSetter: #F8
getters
#F7 isCompleteDeclaration isOriginVariable isStatic foo (nameOffset:<null>) (firstTokenOffset:<null>) (offset:69)
element: <testLibrary>::@extensionType::A::@getter::foo
inducingVariable: #F6
setters
#F8 isCompleteDeclaration isOriginVariable isStatic foo (nameOffset:<null>) (firstTokenOffset:<null>) (offset:69)
element: <testLibrary>::@extensionType::A::@setter::foo
inducingVariable: #F6
formalParameters
#F9 requiredPositional value (nameOffset:<null>) (firstTokenOffset:<null>) (offset:69)
element: <testLibrary>::@extensionType::A::@setter::foo::@formalParameter::value
extensionTypes
isSimplyBounded extension type A
reference: <testLibrary>::@extensionType::A
firstFragment: #F1
representation: <testLibrary>::@extensionType::A::@field::#0
primaryConstructor: <testLibrary>::@extensionType::A::@constructor::new
typeErasure: dynamic
fields
hasImplicitType isFinal isOriginExtensionTypeRecoveryRepresentation <null-name>
reference: <testLibrary>::@extensionType::A::@field::#0
firstFragment: #F3
type: dynamic
getter: <testLibrary>::@extensionType::A::@getter::#1
hasInitializer isOriginDeclaration isStatic foo
reference: <testLibrary>::@extensionType::A::@field::foo
firstFragment: #F6
type: int
getter: <testLibrary>::@extensionType::A::@getter::foo
setter: <testLibrary>::@extensionType::A::@setter::foo
constructors
isConst isExtensionTypeMember isOriginExtensionTypeRecovery isPrimary new
reference: <testLibrary>::@extensionType::A::@constructor::new
firstFragment: #F5
getters
isExtensionTypeMember isOriginVariable <null-name>
reference: <testLibrary>::@extensionType::A::@getter::#1
firstFragment: #F4
returnType: dynamic
variable: <testLibrary>::@extensionType::A::@field::#0
isExtensionTypeMember isOriginVariable isStatic foo
reference: <testLibrary>::@extensionType::A::@getter::foo
firstFragment: #F7
returnType: int
variable: <testLibrary>::@extensionType::A::@field::foo
setters
isExtensionTypeMember isOriginVariable isStatic foo
reference: <testLibrary>::@extensionType::A::@setter::foo
firstFragment: #F8
formalParameters
#E0 requiredPositional value
firstFragment: #F9
type: int
returnType: void
variable: <testLibrary>::@extensionType::A::@field::foo
''');
}
test_extensionType_augmentation_chain_noIntroductoryDeclaration_primaryConstructor() async {
var library = await buildLibrary(r'''
augment extension type A(int it) {
void foo1() {}
}
@@ -6801,6 +7044,218 @@ library
''');
}
test_extensionType_augmentation_chain_noIntroductoryDeclaration_secondaryConstructor() async {
var library = await buildLibrary(r'''
augment extension type A {
A.named();
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
fragments
#F0 <testLibraryFragment>
element: <testLibrary>
extensionTypes
#F1 isAugmentation extension type A (nameOffset:23) (firstTokenOffset:0) (offset:23)
element: <testLibrary>::@extensionType::A
fields
#F2 hasImplicitType isFinal isOriginExtensionTypeRecoveryRepresentation <null-name> (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@field::#0
inducedGetter: #F3
constructors
#F4 isConst isOriginExtensionTypeRecovery isPrimary new (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@constructor::new
typeName: A
#F5 isOriginDeclaration named (nameOffset:31) (firstTokenOffset:29) (offset:31)
element: <testLibrary>::@extensionType::A::@constructor::named
typeName: A
typeNameOffset: 29
periodOffset: 30
getters
#F3 isCompleteDeclaration isOriginVariable <null-name> (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@getter::#1
inducingVariable: #F2
extensionTypes
isSimplyBounded extension type A
reference: <testLibrary>::@extensionType::A
firstFragment: #F1
representation: <testLibrary>::@extensionType::A::@field::#0
primaryConstructor: <testLibrary>::@extensionType::A::@constructor::new
typeErasure: dynamic
fields
hasImplicitType isFinal isOriginExtensionTypeRecoveryRepresentation <null-name>
reference: <testLibrary>::@extensionType::A::@field::#0
firstFragment: #F2
type: dynamic
getter: <testLibrary>::@extensionType::A::@getter::#1
constructors
isConst isExtensionTypeMember isOriginExtensionTypeRecovery isPrimary new
reference: <testLibrary>::@extensionType::A::@constructor::new
firstFragment: #F4
isExtensionTypeMember isOriginDeclaration named
reference: <testLibrary>::@extensionType::A::@constructor::named
firstFragment: #F5
getters
isExtensionTypeMember isOriginVariable <null-name>
reference: <testLibrary>::@extensionType::A::@getter::#1
firstFragment: #F3
returnType: dynamic
variable: <testLibrary>::@extensionType::A::@field::#0
''');
}
test_extensionType_augmentation_chain_noIntroductoryDeclaration_secondaryConstructor_unnamed() async {
var library = await buildLibrary(r'''
augment extension type A {
A();
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
fragments
#F0 <testLibraryFragment>
element: <testLibrary>
extensionTypes
#F1 isAugmentation extension type A (nameOffset:23) (firstTokenOffset:0) (offset:23)
element: <testLibrary>::@extensionType::A
fields
#F2 hasImplicitType isFinal isOriginExtensionTypeRecoveryRepresentation <null-name> (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@field::#0
inducedGetter: #F3
constructors
#F4 isConst isOriginExtensionTypeRecovery isPrimary new (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@constructor::new
typeName: A
#F5 isOriginDeclaration new (nameOffset:<null>) (firstTokenOffset:29) (offset:29)
element: <testLibrary>::@extensionType::A::@constructor::new#1
typeName: A
typeNameOffset: 29
getters
#F3 isCompleteDeclaration isOriginVariable <null-name> (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@getter::#1
inducingVariable: #F2
extensionTypes
isSimplyBounded extension type A
reference: <testLibrary>::@extensionType::A
firstFragment: #F1
representation: <testLibrary>::@extensionType::A::@field::#0
primaryConstructor: <testLibrary>::@extensionType::A::@constructor::new
typeErasure: dynamic
fields
hasImplicitType isFinal isOriginExtensionTypeRecoveryRepresentation <null-name>
reference: <testLibrary>::@extensionType::A::@field::#0
firstFragment: #F2
type: dynamic
getter: <testLibrary>::@extensionType::A::@getter::#1
constructors
isConst isExtensionTypeMember isOriginExtensionTypeRecovery isPrimary new
reference: <testLibrary>::@extensionType::A::@constructor::new
firstFragment: #F4
isExtensionTypeMember isOriginDeclaration new
reference: <testLibrary>::@extensionType::A::@constructor::new#1
firstFragment: #F5
getters
isExtensionTypeMember isOriginVariable <null-name>
reference: <testLibrary>::@extensionType::A::@getter::#1
firstFragment: #F3
returnType: dynamic
variable: <testLibrary>::@extensionType::A::@field::#0
''');
}
test_extensionType_augmentation_chain_noIntroductoryDeclaration_staticField() async {
var library = await buildLibrary(r'''
augment extension type A {
static int foo = 0;
}
''');
checkElementText(library, r'''
library
reference: <testLibrary>
fragments
#F0 <testLibraryFragment>
element: <testLibrary>
extensionTypes
#F1 isAugmentation extension type A (nameOffset:23) (firstTokenOffset:0) (offset:23)
element: <testLibrary>::@extensionType::A
fields
#F2 hasImplicitType isFinal isOriginExtensionTypeRecoveryRepresentation <null-name> (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@field::#0
inducedGetter: #F3
#F4 hasInitializer isOriginDeclaration isStatic foo (nameOffset:40) (firstTokenOffset:40) (offset:40)
element: <testLibrary>::@extensionType::A::@field::foo
inducedGetter: #F5
inducedSetter: #F6
constructors
#F7 isConst isOriginExtensionTypeRecovery isPrimary new (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@constructor::new
typeName: A
getters
#F3 isCompleteDeclaration isOriginVariable <null-name> (nameOffset:<null>) (firstTokenOffset:<null>) (offset:23)
element: <testLibrary>::@extensionType::A::@getter::#1
inducingVariable: #F2
#F5 isCompleteDeclaration isOriginVariable isStatic foo (nameOffset:<null>) (firstTokenOffset:<null>) (offset:40)
element: <testLibrary>::@extensionType::A::@getter::foo
inducingVariable: #F4
setters
#F6 isCompleteDeclaration isOriginVariable isStatic foo (nameOffset:<null>) (firstTokenOffset:<null>) (offset:40)
element: <testLibrary>::@extensionType::A::@setter::foo
inducingVariable: #F4
formalParameters
#F8 requiredPositional value (nameOffset:<null>) (firstTokenOffset:<null>) (offset:40)
element: <testLibrary>::@extensionType::A::@setter::foo::@formalParameter::value
extensionTypes
isSimplyBounded extension type A
reference: <testLibrary>::@extensionType::A
firstFragment: #F1
representation: <testLibrary>::@extensionType::A::@field::#0
primaryConstructor: <testLibrary>::@extensionType::A::@constructor::new
typeErasure: dynamic
fields
hasImplicitType isFinal isOriginExtensionTypeRecoveryRepresentation <null-name>
reference: <testLibrary>::@extensionType::A::@field::#0
firstFragment: #F2
type: dynamic
getter: <testLibrary>::@extensionType::A::@getter::#1
hasInitializer isOriginDeclaration isStatic foo
reference: <testLibrary>::@extensionType::A::@field::foo
firstFragment: #F4
type: int
getter: <testLibrary>::@extensionType::A::@getter::foo
setter: <testLibrary>::@extensionType::A::@setter::foo
constructors
isConst isExtensionTypeMember isOriginExtensionTypeRecovery isPrimary new
reference: <testLibrary>::@extensionType::A::@constructor::new
firstFragment: #F7
getters
isExtensionTypeMember isOriginVariable <null-name>
reference: <testLibrary>::@extensionType::A::@getter::#1
firstFragment: #F3
returnType: dynamic
variable: <testLibrary>::@extensionType::A::@field::#0
isExtensionTypeMember isOriginVariable isStatic foo
reference: <testLibrary>::@extensionType::A::@getter::foo
firstFragment: #F5
returnType: int
variable: <testLibrary>::@extensionType::A::@field::foo
setters
isExtensionTypeMember isOriginVariable isStatic foo
reference: <testLibrary>::@extensionType::A::@setter::foo
firstFragment: #F6
formalParameters
#E0 requiredPositional value
firstFragment: #F8
type: int
returnType: void
variable: <testLibrary>::@extensionType::A::@field::foo
''');
}
test_extensionType_augmentation_chain_twoDeclarations() async {
var library = await buildLibrary(r'''
extension type A(int it) {}
@@ -455,7 +455,7 @@ class _DartNavigationComputerVisitor extends RecursiveAstVisitor<void> {
@override
void visitExtensionTypeDeclaration(ExtensionTypeDeclaration node) {
computer._addRegionForFragment(
node.primaryConstructor.typeName,
node.namePart.typeName,
node.declaredFragment,
);
super.visitExtensionTypeDeclaration(node);
+1 -1
View File
@@ -85,7 +85,7 @@ SyntacticEntity getNodeToAnnotate(AstNode node) {
} else if (node is VariableDeclaration) {
return node.name;
} else if (node is ExtensionTypeDeclaration) {
return node.primaryConstructor.typeName;
return node.namePart.typeName;
}
assert(false, "Unaccounted for node type: '${node.runtimeType}'");
return node;
+1 -2
View File
@@ -53,8 +53,7 @@ extension AstNodeExtension on AstNode {
ClassDeclaration() => parent.namePart.typeName.isPrivate,
EnumDeclaration() => parent.namePart.typeName.isPrivate,
ExtensionDeclaration() => parent.name == null || parent.name.isPrivate,
ExtensionTypeDeclaration() =>
parent.primaryConstructor.typeName.isPrivate,
ExtensionTypeDeclaration() => parent.namePart.typeName.isPrivate,
MixinDeclaration() => parent.name.isPrivate,
_ => false,
};
@@ -129,7 +129,7 @@ class _Visitor extends SimpleAstVisitor<void> {
} else if (parent is ExtensionTypeDeclaration) {
_checkForShadowing(
typeParameters,
parent.primaryConstructor.typeParameters,
parent.namePart.typeParameters,
'extension type',
);
} else if (parent is MethodDeclaration) {
@@ -75,7 +75,7 @@ class _Visitor extends SimpleAstVisitor<void> {
void visitExtensionTypeDeclaration(ExtensionTypeDeclaration node) {
if (node.isAugmentation) return;
check(node.primaryConstructor.typeName);
check(node.namePart.typeName);
}
@override
@@ -93,17 +93,19 @@ class Validator extends SimpleAstVisitor<void> {
@override
void visitExtensionTypeDeclaration(ExtensionTypeDeclaration node) {
if (Identifier.isPrivateName(node.primaryConstructor.typeName.lexeme)) {
var namePart = node.namePart;
if (Identifier.isPrivateName(namePart.typeName.lexeme)) {
return;
}
node.primaryConstructor.typeParameters?.accept(this);
namePart.typeParameters?.accept(this);
for (var formalParameter
in node.primaryConstructor.formalParameters.parameters) {
if (formalParameter is RegularFormalParameter) {
var name = formalParameter.name;
if (name != null && !Identifier.isPrivateName(name.lexeme)) {
formalParameter.type?.accept(this);
if (namePart is PrimaryConstructorDeclaration) {
for (var formalParameter in namePart.formalParameters.parameters) {
if (formalParameter is RegularFormalParameter) {
var name = formalParameter.name;
if (name != null && !Identifier.isPrivateName(name.lexeme)) {
formalParameter.type?.accept(this);
}
}
}
}
@@ -89,7 +89,9 @@ class _Visitor extends SimpleAstVisitor<void> {
@override
void visitExtensionTypeDeclaration(ExtensionTypeDeclaration node) {
checkIdentifier(node.primaryConstructor.constructorName?.name);
if (node.namePart case PrimaryConstructorDeclaration primaryConstructor) {
checkIdentifier(primaryConstructor.constructorName?.name);
}
}
@override
@@ -87,7 +87,7 @@ class _Visitor extends SimpleAstVisitor<void> {
extension on AstNode? {
InterfaceType? typeToCheckOrNull() => switch (this) {
ExtensionTypeDeclaration e =>
e.primaryConstructor.typeParameters == null
e.namePart.typeParameters == null
? e.declaredFragment?.element.thisType
: null,
ClassDeclaration c =>
@@ -215,7 +215,7 @@ class _Visitor extends SimpleAstVisitor<void> {
@override
void visitExtensionTypeDeclaration(ExtensionTypeDeclaration node) {
if (node.declaredFragment?.element == null) return;
_visitMembers(node, node.primaryConstructor.typeName, node.body.members);
_visitMembers(node, node.namePart.typeName, node.body.members);
}
@override
@@ -52,9 +52,12 @@ class _Visitor extends SimpleAstVisitor<void> {
return;
}
var parent = node.parent?.parent;
if (parent is ExtensionTypeDeclaration &&
parent.primaryConstructor.constructorName == null) {
return;
if (parent is ExtensionTypeDeclaration) {
var namePart = parent.namePart;
if (namePart is PrimaryConstructorDeclaration &&
namePart.constructorName == null) {
return;
}
}
_check(node.name);
@@ -718,7 +718,7 @@ extension on Declaration {
var name = self.name;
return name?.lexeme ?? 'the unnamed extension';
case ExtensionTypeDeclaration():
return self.primaryConstructor.typeName.lexeme;
return self.namePart.typeName.lexeme;
case FunctionDeclaration():
return self.name.lexeme;
case MethodDeclaration():