From 30cb4d44e43c300034bae795fbfd759e96d7fcc2 Mon Sep 17 00:00:00 2001 From: Johnni Winther Date: Fri, 18 Aug 2023 12:49:53 +0000 Subject: [PATCH] [cfe] Handle extension type in fuzz testing Closes #53115 Closes #53117 Change-Id: Id34594b246a86f1c62dfc41d55a783a737a300ee Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321680 Commit-Queue: Johnni Winther Reviewed-by: Jens Johansen --- .../kernel/constructor_tearoff_lowering.dart | 21 +++--- .../lib/src/fasta/kernel/kernel_target.dart | 21 +++--- .../lib/src/fasta/source/outline_builder.dart | 26 ++++++- .../source/source_constructor_builder.dart | 30 ++++---- .../fasta/source/source_factory_builder.dart | 18 +++-- .../fasta/source/source_library_builder.dart | 71 +++++++++++++------ .../lib/src/fasta/util/parser_ast.dart | 53 ++++++++++++++ pkg/front_end/test/fasta/testing/suite.dart | 9 +++ .../extension_type_declaration.yaml | 54 ++++++++++++++ ...nsion_type_declaration.yaml.world.1.expect | 48 +++++++++++++ ...nsion_type_declaration.yaml.world.2.expect | 48 +++++++++++++ .../has_export.dart.strong.expect | 4 +- .../has_export.dart.strong.transformed.expect | 4 +- .../has_export.dart.weak.expect | 4 +- .../has_export.dart.weak.modular.expect | 4 +- .../has_export.dart.weak.outline.expect | 4 +- .../has_export.dart.weak.transformed.expect | 4 +- .../has_export.dart.strong.expect | 4 +- .../has_export.dart.strong.transformed.expect | 4 +- .../inline_class/has_export.dart.weak.expect | 4 +- .../has_export.dart.weak.modular.expect | 4 +- .../has_export.dart.weak.outline.expect | 4 +- .../has_export.dart.weak.transformed.expect | 4 +- pkg/front_end/testcases/weak.status | 57 +-------------- pkg/kernel/lib/src/equivalence_helpers.dart | 4 ++ 25 files changed, 360 insertions(+), 148 deletions(-) create mode 100644 pkg/front_end/testcases/incremental/extension_type_declaration.yaml create mode 100644 pkg/front_end/testcases/incremental/extension_type_declaration.yaml.world.1.expect create mode 100644 pkg/front_end/testcases/incremental/extension_type_declaration.yaml.world.2.expect diff --git a/pkg/front_end/lib/src/fasta/kernel/constructor_tearoff_lowering.dart b/pkg/front_end/lib/src/fasta/kernel/constructor_tearoff_lowering.dart index 9cd5b39e5a6..bc6101ebc4a 100644 --- a/pkg/front_end/lib/src/fasta/kernel/constructor_tearoff_lowering.dart +++ b/pkg/front_end/lib/src/fasta/kernel/constructor_tearoff_lowering.dart @@ -96,7 +96,7 @@ bool isTypedefTearOffLowering(Procedure procedure) { /// /// If constructor tear off lowering is not enabled, `null` is returned. Procedure? createConstructorTearOffProcedure( - String name, + MemberName tearOffName, SourceLibraryBuilder compilationUnit, Uri fileUri, int fileOffset, @@ -107,8 +107,8 @@ Procedure? createConstructorTearOffProcedure( (forceCreateLowering || compilationUnit.loader.target.backendTarget .isConstructorTearOffLoweringEnabled)) { - return _createTearOffProcedure(compilationUnit, - constructorTearOffName(name), fileUri, fileOffset, reference); + return _createTearOffProcedure( + compilationUnit, tearOffName, fileUri, fileOffset, reference); } return null; } @@ -118,7 +118,7 @@ Procedure? createConstructorTearOffProcedure( /// /// If constructor tear off lowering is not enabled, `null` is returned. Procedure? createFactoryTearOffProcedure( - String name, + MemberName tearOffName, SourceLibraryBuilder compilationUnit, Uri fileUri, int fileOffset, @@ -127,8 +127,8 @@ Procedure? createFactoryTearOffProcedure( if (forceCreateLowering || compilationUnit .loader.target.backendTarget.isFactoryTearOffLoweringEnabled) { - return _createTearOffProcedure(compilationUnit, - constructorTearOffName(name), fileUri, fileOffset, reference); + return _createTearOffProcedure( + compilationUnit, tearOffName, fileUri, fileOffset, reference); } return null; } @@ -143,8 +143,10 @@ Procedure createTypedefTearOffProcedure( Uri fileUri, int fileOffset, Reference? reference) { - return _createTearOffProcedure(libraryBuilder, - typedefTearOffName(typedefName, name), fileUri, fileOffset, reference); + MemberName tearOffName = new MemberName( + libraryBuilder.libraryName, typedefTearOffName(typedefName, name)); + return _createTearOffProcedure( + libraryBuilder, tearOffName, fileUri, fileOffset, reference); } /// Creates the parameters and body for [tearOff] based on @@ -348,7 +350,7 @@ DelayedDefaultValueCloner buildRedirectingFactoryTearOffBody( /// Creates the synthesized [Procedure] node for a tear off lowering by the /// given [name]. Procedure _createTearOffProcedure(SourceLibraryBuilder libraryBuilder, - String name, Uri fileUri, int fileOffset, Reference? reference) { + MemberName tearOffName, Uri fileUri, int fileOffset, Reference? reference) { Procedure tearOff = new Procedure( dummyName, ProcedureKind.Method, new FunctionNode(null), fileUri: fileUri, isStatic: true, isSynthetic: true, reference: reference) @@ -356,7 +358,6 @@ Procedure _createTearOffProcedure(SourceLibraryBuilder libraryBuilder, ..fileOffset = fileOffset ..fileEndOffset = fileOffset ..isNonNullableByDefault = libraryBuilder.isNonNullableByDefault; - MemberName tearOffName = new MemberName(libraryBuilder.libraryName, name); tearOffName.attachMember(tearOff); return tearOff; } diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart index ffcb144d39a..136d347a186 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart @@ -65,6 +65,7 @@ import '../problems.dart' show unhandled; import '../scope.dart' show AmbiguousBuilder; import '../source/class_declaration.dart'; import '../source/constructor_declaration.dart'; +import '../source/name_scheme.dart'; import '../source/source_class_builder.dart' show SourceClassBuilder; import '../source/source_constructor_builder.dart'; import '../source/source_extension_type_declaration_builder.dart'; @@ -1007,6 +1008,7 @@ class KernelTarget extends TargetImplementation { return copy; } + SourceLibraryBuilder libraryBuilder = classBuilder.libraryBuilder; Class cls = classBuilder.cls; Constructor superConstructor = superConstructorBuilder.member as Constructor; @@ -1059,7 +1061,7 @@ class KernelTarget extends TargetImplementation { DelayedDefaultValueCloner delayedDefaultValueCloner = new DelayedDefaultValueCloner( superConstructor, constructor, substitutionMap, - libraryBuilder: classBuilder.libraryBuilder); + libraryBuilder: libraryBuilder); TypeDependency? typeDependency; if (hasTypeDependency) { @@ -1069,8 +1071,9 @@ class KernelTarget extends TargetImplementation { } Procedure? constructorTearOff = createConstructorTearOffProcedure( - superConstructor.name.text, - classBuilder.libraryBuilder, + new MemberName(libraryBuilder.libraryName, + constructorTearOffName(superConstructor.name.text)), + libraryBuilder, cls.fileUri, cls.fileOffset, tearOffReference, @@ -1082,7 +1085,7 @@ class KernelTarget extends TargetImplementation { declarationConstructor: constructor, implementationConstructor: constructor, enclosingDeclarationTypeParameters: classBuilder.cls.typeParameters, - libraryBuilder: classBuilder.libraryBuilder); + libraryBuilder: libraryBuilder); } SyntheticSourceConstructorBuilder constructorBuilder = new SyntheticSourceConstructorBuilder( @@ -1133,6 +1136,7 @@ class KernelTarget extends TargetImplementation { SourceClassBuilder classBuilder, Reference? constructorReference, Reference? tearOffReference) { + SourceLibraryBuilder libraryBuilder = classBuilder.libraryBuilder; Class enclosingClass = classBuilder.cls; Constructor constructor = new Constructor( new FunctionNode(new EmptyStatement(), @@ -1145,11 +1149,10 @@ class KernelTarget extends TargetImplementation { // TODO(johnniwinther): Should we add file end offsets to synthesized // constructors? //..fileEndOffset = enclosingClass.fileOffset - ..isNonNullableByDefault = - enclosingClass.enclosingLibrary.isNonNullableByDefault; + ..isNonNullableByDefault = libraryBuilder.isNonNullableByDefault; Procedure? constructorTearOff = createConstructorTearOffProcedure( - '', - classBuilder.libraryBuilder, + new MemberName(libraryBuilder.libraryName, constructorTearOffName('')), + libraryBuilder, enclosingClass.fileUri, enclosingClass.fileOffset, tearOffReference, @@ -1161,7 +1164,7 @@ class KernelTarget extends TargetImplementation { declarationConstructor: constructor, implementationConstructor: constructor, enclosingDeclarationTypeParameters: classBuilder.cls.typeParameters, - libraryBuilder: classBuilder.libraryBuilder); + libraryBuilder: libraryBuilder); } return new SyntheticSourceConstructorBuilder( classBuilder, constructor, constructorTearOff); diff --git a/pkg/front_end/lib/src/fasta/source/outline_builder.dart b/pkg/front_end/lib/src/fasta/source/outline_builder.dart index ef444e85ac2..28bf8002ac2 100644 --- a/pkg/front_end/lib/src/fasta/source/outline_builder.dart +++ b/pkg/front_end/lib/src/fasta/source/outline_builder.dart @@ -1747,7 +1747,8 @@ class OutlineBuilder extends StackListenerImpl { nativeMethodName, asyncModifier, isInstanceMember: false, - isExtensionMember: false); + isExtensionMember: false, + isExtensionTypeMember: false); nativeMethodName = null; } popDeclarationContext(DeclarationContext.TopLevelMethod); @@ -1935,6 +1936,13 @@ class OutlineBuilder extends StackListenerImpl { endToken, _MethodKind.extensionMethod); } + @override + void endExtensionTypeMethod(Token? getOrSet, Token beginToken, + Token beginParam, Token? beginInitializers, Token endToken) { + _endClassMethod(getOrSet, beginToken, beginParam, beginInitializers, + endToken, _MethodKind.extensionTypeMethod); + } + @override void endMixinConstructor(Token? getOrSet, Token beginToken, Token beginParam, Token? beginInitializers, Token endToken) { @@ -1949,6 +1957,13 @@ class OutlineBuilder extends StackListenerImpl { endToken, _MethodKind.extensionConstructor); } + @override + void endExtensionTypeConstructor(Token? getOrSet, Token beginToken, + Token beginParam, Token? beginInitializers, Token endToken) { + _endClassMethod(getOrSet, beginToken, beginParam, beginInitializers, + endToken, _MethodKind.extensionTypeConstructor); + } + (List?, Map?) _createSyntheticTypeVariables( TypeParameterScopeBuilder enclosingDeclarationScopeBuilder, @@ -2124,6 +2139,7 @@ class OutlineBuilder extends StackListenerImpl { case _MethodKind.classConstructor: case _MethodKind.mixinConstructor: case _MethodKind.extensionConstructor: + case _MethodKind.extensionTypeConstructor: case _MethodKind.enumConstructor: constructorName = libraryBuilder.computeAndValidateConstructorName( name, charOffset) ?? @@ -2132,6 +2148,7 @@ class OutlineBuilder extends StackListenerImpl { case _MethodKind.classMethod: case _MethodKind.mixinMethod: case _MethodKind.extensionMethod: + case _MethodKind.extensionTypeMethod: case _MethodKind.enumMethod: break; } @@ -2243,6 +2260,8 @@ class OutlineBuilder extends StackListenerImpl { ? beginToken.charOffset : metadata.first.charOffset; bool isExtensionMember = methodKind == _MethodKind.extensionMethod; + bool isExtensionTypeMember = + methodKind == _MethodKind.extensionTypeMethod; libraryBuilder.addProcedure( metadata, modifiers, @@ -2258,7 +2277,8 @@ class OutlineBuilder extends StackListenerImpl { nativeMethodName, asyncModifier, isInstanceMember: !isStatic, - isExtensionMember: isExtensionMember); + isExtensionMember: isExtensionMember, + isExtensionTypeMember: isExtensionTypeMember); } } nativeMethodName = null; @@ -3903,6 +3923,8 @@ enum _MethodKind { mixinMethod, extensionConstructor, extensionMethod, + extensionTypeConstructor, + extensionTypeMethod, enumConstructor, enumMethod, } diff --git a/pkg/front_end/lib/src/fasta/source/source_constructor_builder.dart b/pkg/front_end/lib/src/fasta/source/source_constructor_builder.dart index ecfd00c70bf..c92af93328b 100644 --- a/pkg/front_end/lib/src/fasta/source/source_constructor_builder.dart +++ b/pkg/front_end/lib/src/fasta/source/source_constructor_builder.dart @@ -388,14 +388,13 @@ class DeclaredSourceConstructorBuilder nameScheme .getConstructorMemberName(name, isTearOff: false) .attachMember(_constructor); - _constructorTearOff = createConstructorTearOffProcedure(name, - compilationUnit, compilationUnit.fileUri, charOffset, tearOffReference, + _constructorTearOff = createConstructorTearOffProcedure( + nameScheme.getConstructorMemberName(name, isTearOff: true), + compilationUnit, + compilationUnit.fileUri, + charOffset, + tearOffReference, forAbstractClassOrEnumOrMixin: forAbstractClassOrEnumOrMixin); - if (_constructorTearOff != null) { - nameScheme - .getConstructorMemberName(name, isTearOff: true) - .attachMember(_constructorTearOff!); - } } @override @@ -1115,16 +1114,15 @@ class SourceExtensionTypeConstructorBuilder nameScheme .getConstructorMemberName(name, isTearOff: false) .attachMember(_constructor); - _constructorTearOff = createConstructorTearOffProcedure(name, - compilationUnit, compilationUnit.fileUri, charOffset, tearOffReference, + _constructorTearOff = createConstructorTearOffProcedure( + nameScheme.getConstructorMemberName(name, isTearOff: true), + compilationUnit, + compilationUnit.fileUri, + charOffset, + tearOffReference, forAbstractClassOrEnumOrMixin: forAbstractClassOrEnumOrMixin, - forceCreateLowering: true); - if (_constructorTearOff != null) { - nameScheme - .getConstructorMemberName(name, isTearOff: true) - .attachMember(_constructorTearOff!); - _constructorTearOff!.isExtensionTypeMember = true; - } + forceCreateLowering: true) + ?..isExtensionTypeMember = true; } @override diff --git a/pkg/front_end/lib/src/fasta/source/source_factory_builder.dart b/pkg/front_end/lib/src/fasta/source/source_factory_builder.dart index 095717103fe..16e9c7d4511 100644 --- a/pkg/front_end/lib/src/fasta/source/source_factory_builder.dart +++ b/pkg/front_end/lib/src/fasta/source/source_factory_builder.dart @@ -96,16 +96,14 @@ class SourceFactoryBuilder extends SourceFunctionBuilderImpl { nameScheme .getProcedureMemberName(ProcedureKind.Factory, name) .attachMember(_procedureInternal); - _factoryTearOff = createFactoryTearOffProcedure(name, libraryBuilder, - libraryBuilder.fileUri, charOffset, tearOffReference, - forceCreateLowering: nameScheme.isExtensionTypeMember); - if (_factoryTearOff != null) { - _factoryTearOff! - ..isExtensionTypeMember = nameScheme.isExtensionTypeMember; - nameScheme - .getConstructorMemberName(name, isTearOff: true) - .attachMember(_factoryTearOff!); - } + _factoryTearOff = createFactoryTearOffProcedure( + nameScheme.getConstructorMemberName(name, isTearOff: true), + libraryBuilder, + libraryBuilder.fileUri, + charOffset, + tearOffReference, + forceCreateLowering: nameScheme.isExtensionTypeMember) + ?..isExtensionTypeMember = nameScheme.isExtensionTypeMember; this.asyncModifier = asyncModifier; } diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart index ffb1843a579..4204f19d50e 100644 --- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart +++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart @@ -70,7 +70,6 @@ import '../fasta_codes.dart'; import '../identifiers.dart' show QualifiedName, flattenName; import '../import.dart' show Import; import '../kernel/body_builder_context.dart'; -import '../kernel/constructor_tearoff_lowering.dart'; import '../kernel/hierarchy/members_builder.dart'; import '../kernel/internal_ast.dart'; import '../kernel/kernel_helper.dart'; @@ -3012,19 +3011,6 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { String? nativeMethodName, {Token? beginInitializers, required bool forAbstractClassOrMixin}) { - Reference? constructorReference; - Reference? tearOffReference; - if (_currentClassReferencesFromIndexed != null) { - constructorReference = _currentClassReferencesFromIndexed! - .lookupConstructorReference(new Name( - constructorName, _currentClassReferencesFromIndexed!.library)); - tearOffReference = _currentClassReferencesFromIndexed! - .lookupGetterReference(new Name( - constructorTearOffName(constructorName), - _currentClassReferencesFromIndexed!.library)); - } - AbstractSourceConstructorBuilder constructorBuilder; - ContainerType containerType = currentTypeParameterScopeBuilder.containerType; ContainerName? containerName = @@ -3036,6 +3022,30 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { libraryName: referencesFrom != null ? new LibraryName(referencesFrom!.reference) : libraryName); + + Reference? constructorReference; + Reference? tearOffReference; + + if (_currentClassReferencesFromIndexed != null) { + constructorReference = _currentClassReferencesFromIndexed! + .lookupConstructorReference(nameScheme + .getConstructorMemberName(constructorName, isTearOff: false) + .name); + tearOffReference = _currentClassReferencesFromIndexed! + .lookupGetterReference(nameScheme + .getConstructorMemberName(constructorName, isTearOff: true) + .name); + } else if (referencesFromIndexed != null) { + constructorReference = referencesFromIndexed!.lookupGetterReference( + nameScheme + .getConstructorMemberName(constructorName, isTearOff: false) + .name); + tearOffReference = referencesFromIndexed!.lookupGetterReference(nameScheme + .getConstructorMemberName(constructorName, isTearOff: true) + .name); + } + AbstractSourceConstructorBuilder constructorBuilder; + if (currentTypeParameterScopeBuilder.kind == TypeParameterScopeKind.inlineClassDeclaration || currentTypeParameterScopeBuilder.kind == @@ -3111,10 +3121,14 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { String? nativeMethodName, AsyncMarker asyncModifier, {required bool isInstanceMember, - required bool isExtensionMember}) { + required bool isExtensionMember, + required bool isExtensionTypeMember}) { assert(!isExtensionMember || currentTypeParameterScopeBuilder.kind == TypeParameterScopeKind.extensionDeclaration); + assert(!isExtensionTypeMember || + currentTypeParameterScopeBuilder.kind == + TypeParameterScopeKind.extensionTypeDeclaration); ContainerType containerType = currentTypeParameterScopeBuilder.containerType; ContainerName? containerName = @@ -3149,15 +3163,17 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { } } else { if (kind == ProcedureKind.Setter && - // Extension instance setters are encoded as methods. - !(isExtensionMember && isInstanceMember)) { + // Extension (type) instance setters are encoded as methods. + !((isExtensionMember || isExtensionTypeMember) && + isInstanceMember)) { procedureReference = referencesFromIndexed!.lookupSetterReference(nameToLookup); } else { procedureReference = referencesFromIndexed!.lookupGetterReference(nameToLookup); } - if (isExtensionMember && kind == ProcedureKind.Method) { + if ((isExtensionMember || isExtensionTypeMember) && + kind == ProcedureKind.Method) { tearOffReference = referencesFromIndexed!.lookupGetterReference( nameScheme .getProcedureMemberName(ProcedureKind.Getter, name) @@ -3252,11 +3268,22 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { Reference? tearOffReference; if (_currentClassReferencesFromIndexed != null) { constructorReference = _currentClassReferencesFromIndexed! - .lookupConstructorReference(new Name( - procedureName, _currentClassReferencesFromIndexed!.library)); + .lookupConstructorReference(procedureNameScheme + .getConstructorMemberName(procedureName, isTearOff: false) + .name); tearOffReference = _currentClassReferencesFromIndexed! - .lookupGetterReference(new Name(constructorTearOffName(procedureName), - _currentClassReferencesFromIndexed!.library)); + .lookupGetterReference(procedureNameScheme + .getConstructorMemberName(procedureName, isTearOff: true) + .name); + } else if (referencesFromIndexed != null) { + constructorReference = referencesFromIndexed!.lookupGetterReference( + procedureNameScheme + .getConstructorMemberName(procedureName, isTearOff: false) + .name); + tearOffReference = referencesFromIndexed!.lookupGetterReference( + procedureNameScheme + .getConstructorMemberName(procedureName, isTearOff: true) + .name); } SourceFactoryBuilder procedureBuilder; diff --git a/pkg/front_end/lib/src/fasta/util/parser_ast.dart b/pkg/front_end/lib/src/fasta/util/parser_ast.dart index fce7f226bf9..eee45495c87 100644 --- a/pkg/front_end/lib/src/fasta/util/parser_ast.dart +++ b/pkg/front_end/lib/src/fasta/util/parser_ast.dart @@ -137,6 +137,11 @@ class ParserAstVisitor { visitExtensionMethod(method, method.beginToken, method.endToken); return; } + if (node is ExtensionTypeMethodEnd) { + ExtensionTypeMethodEnd method = node; + visitExtensionTypeMethod(method, method.beginToken, method.endToken); + return; + } if (node is MixinMethodEnd) { MixinMethodEnd method = node; visitMixinMethod(method, method.beginToken, method.endToken); @@ -173,6 +178,13 @@ class ParserAstVisitor { visitExtensionFields(fields, fields.beginToken, fields.endToken); return; } + if (node is ExtensionTypeFieldsEnd) { + // TODO(jensj): Possibly this could go into more details too + // (e.g. to split up a field declaration). + ExtensionTypeFieldsEnd fields = node; + visitExtensionTypeFields(fields, fields.beginToken, fields.endToken); + return; + } if (node is MixinFieldsEnd) { // TODO(jensj): Possibly this could go into more details too // (e.g. to split up a field declaration). @@ -216,6 +228,11 @@ class ParserAstVisitor { visitExtension(ext, ext.extensionKeyword, ext.endToken); return; } + if (node is ExtensionTypeDeclarationEnd) { + ExtensionTypeDeclarationEnd ext = node; + visitExtensionTypeDeclaration(ext, ext.extensionKeyword, ext.endToken); + return; + } if (node is ClassConstructorEnd) { ClassConstructorEnd decl = node; visitClassConstructor(decl, decl.beginToken, decl.endToken); @@ -226,6 +243,11 @@ class ParserAstVisitor { visitExtensionConstructor(decl, decl.beginToken, decl.endToken); return; } + if (node is ExtensionTypeConstructorEnd) { + ExtensionTypeConstructorEnd decl = node; + visitExtensionTypeConstructor(decl, decl.beginToken, decl.endToken); + return; + } if (node is ClassFactoryMethodEnd) { ClassFactoryMethodEnd decl = node; visitClassFactoryMethod(decl, decl.beginToken, decl.endToken); @@ -236,6 +258,11 @@ class ParserAstVisitor { visitExtensionFactoryMethod(decl, decl.beginToken, decl.endToken); return; } + if (node is ExtensionTypeFactoryMethodEnd) { + ExtensionTypeFactoryMethodEnd decl = node; + visitExtensionTypeFactoryMethod(decl, decl.beginToken, decl.endToken); + return; + } if (node is MetadataEnd) { MetadataEnd decl = node; // TODO(jensj): endToken is not part of the metadata! It's the first token @@ -289,6 +316,10 @@ class ParserAstVisitor { void visitExtensionMethod( ExtensionMethodEnd node, Token startInclusive, Token endInclusive) {} + /// Note: Implementers are NOT expected to call visitChildren on this node. + void visitExtensionTypeMethod( + ExtensionTypeMethodEnd node, Token startInclusive, Token endInclusive) {} + /// Note: Implementers are NOT expected to call visitChildren on this node. void visitMixinMethod( MixinMethodEnd node, Token startInclusive, Token endInclusive) {} @@ -305,6 +336,10 @@ class ParserAstVisitor { void visitExtensionFields( ExtensionFieldsEnd node, Token startInclusive, Token endInclusive) {} + /// Note: Implementers are NOT expected to call visitChildren on this node. + void visitExtensionTypeFields( + ExtensionTypeFieldsEnd node, Token startInclusive, Token endInclusive) {} + /// Note: Implementers are NOT expected to call visitChildren on this node. void visitMixinFields( MixinFieldsEnd node, Token startInclusive, Token endInclusive) {} @@ -340,6 +375,12 @@ class ParserAstVisitor { visitChildren(node); } + /// Note: Implementers can call visitChildren on this node. + void visitExtensionTypeDeclaration(ExtensionTypeDeclarationEnd node, + Token startInclusive, Token endInclusive) { + visitChildren(node); + } + /// Note: Implementers are NOT expected to call visitChildren on this node. void visitClassConstructor( ClassConstructorEnd node, Token startInclusive, Token endInclusive) {} @@ -348,6 +389,10 @@ class ParserAstVisitor { void visitExtensionConstructor( ExtensionConstructorEnd node, Token startInclusive, Token endInclusive) {} + /// Note: Implementers are NOT expected to call visitChildren on this node. + void visitExtensionTypeConstructor(ExtensionTypeConstructorEnd node, + Token startInclusive, Token endInclusive) {} + /// Note: Implementers are NOT expected to call visitChildren on this node. void visitClassFactoryMethod( ClassFactoryMethodEnd node, Token startInclusive, Token endInclusive) {} @@ -356,6 +401,10 @@ class ParserAstVisitor { void visitExtensionFactoryMethod(ExtensionFactoryMethodEnd node, Token startInclusive, Token endInclusive) {} + /// Note: Implementers are NOT expected to call visitChildren on this node. + void visitExtensionTypeFactoryMethod(ExtensionTypeFactoryMethodEnd node, + Token startInclusive, Token endInclusive) {} + /// Note: Implementers are NOT expected to call visitChildren on this node. void visitMetadata( MetadataEnd node, Token startInclusive, Token endInclusive) {} @@ -1516,6 +1565,8 @@ class ParserASTListener extends AbstractParserAstListener { end == "ClassMethod" || end == "ExtensionConstructor" || end == "ExtensionMethod" || + end == "ExtensionTypeConstructor" || + end == "ExtensionTypeMethod" || end == "MixinConstructor" || end == "MixinMethod" || end == "EnumConstructor" || @@ -1528,6 +1579,7 @@ class ParserASTListener extends AbstractParserAstListener { end == "ClassFields" || end == "MixinFields" || end == "ExtensionFields" || + end == "ExtensionTypeFields" || end == "EnumFields")) { // beginFields is ended by one of endTopLevelFields, endMixinFields, // endEnumFields or endExtensionFields. @@ -1537,6 +1589,7 @@ class ParserASTListener extends AbstractParserAstListener { (end == "ClassFactoryMethod" || end == "MixinFactoryMethod" || end == "ExtensionFactoryMethod" || + end == "ExtensionTypeFactoryMethod" || end == "EnumFactoryMethod")) { // beginFactoryMethod is ended by either endClassFactoryMethod, // endMixinFactoryMethod, endExtensionFactoryMethod, or diff --git a/pkg/front_end/test/fasta/testing/suite.dart b/pkg/front_end/test/fasta/testing/suite.dart index dd9c0d3bf19..dbf6cf0ef63 100644 --- a/pkg/front_end/test/fasta/testing/suite.dart +++ b/pkg/front_end/test/fasta/testing/suite.dart @@ -1585,6 +1585,7 @@ enum FuzzOriginalType { Mixin, Enum, Extension, + ExtensionTypeDeclaration, LibraryName, Part, PartOf, @@ -1754,6 +1755,14 @@ class FuzzAstVisitorSorter extends ParserAstVisitor { startInclusive, endInclusive); } + @override + void visitExtensionTypeDeclaration(ExtensionTypeDeclarationEnd node, + Token startInclusive, Token endInclusive) { + // TODO(jensj): Possibly sort stuff inside of this too. + handleData(FuzzOriginalType.ExtensionTypeDeclaration, + FuzzSorterState.sortableRest, startInclusive, endInclusive); + } + @override void visitLibraryName( LibraryNameEnd node, Token startInclusive, Token endInclusive) { diff --git a/pkg/front_end/testcases/incremental/extension_type_declaration.yaml b/pkg/front_end/testcases/incremental/extension_type_declaration.yaml new file mode 100644 index 00000000000..6264fb41992 --- /dev/null +++ b/pkg/front_end/testcases/incremental/extension_type_declaration.yaml @@ -0,0 +1,54 @@ +# Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file +# for details. All rights reserved. Use of this source code is governed by a +# BSD-style license that can be found in the LICENSE.md file. + +# Test extension on String from import from dill. + +type: newworld +worlds: + - entry: main.dart + sources: + main.dart: | + extension type ExtensionType(int i) { + factory ExtensionType.f(int i) => ExtensionType(i); + factory ExtensionType.r(int i) = ExtensionType; + int method() => i; + int get getter => i; + void set setter(int value) {} + static void staticMethod() {} + static int staticField = 42; + } + main() { + ExtensionType(0).method(); + ExtensionType.f(0).getter; + ExtensionType.r(0).setter = 42; + ExtensionType.staticMethod(); + ExtensionType.staticField = ExtensionType.staticField + 1; + } + expectedLibraryCount: 1 + experiments: inline-class + - entry: main.dart + invalidate: + - main.dart + sources: + main.dart: | + extension type ExtensionType(int i) { + factory ExtensionType.f(int i) => ExtensionType(i); + factory ExtensionType.r(int i) = ExtensionType; + int method() => i; + int get getter => i; + void set setter(int value) {} + static void staticMethod() {} + static int staticField = 42; + } + main() { + ExtensionType(1).method(); + ExtensionType.f(1).getter; + ExtensionType.r(1).setter = 42; + ExtensionType.staticMethod(); + ExtensionType.staticField = ExtensionType.staticField + 2; + } + expectedLibraryCount: 1 + experiments: inline-class + advancedInvalidation: bodiesOnly + diff --git a/pkg/front_end/testcases/incremental/extension_type_declaration.yaml.world.1.expect b/pkg/front_end/testcases/incremental/extension_type_declaration.yaml.world.1.expect new file mode 100644 index 00000000000..50f1ac15474 --- /dev/null +++ b/pkg/front_end/testcases/incremental/extension_type_declaration.yaml.world.1.expect @@ -0,0 +1,48 @@ +main = main::main; +library from "org-dartlang-test:///main.dart" as main { + + extension type ExtensionType(dart.core::int i) { + method method = main::ExtensionType|method; + tearoff method = main::ExtensionType|get#method; + get getter = main::ExtensionType|get#getter; + static method staticMethod = main::ExtensionType|staticMethod; + static field staticField = main::ExtensionType|staticField; + set setter = main::ExtensionType|set#setter; + constructor • = main::ExtensionType|; + tearoff • = main::ExtensionType|_#new#tearOff; + static factory f = main::ExtensionType|f; + static tearoff f = main::ExtensionType|_#f#tearOff; + static redirecting-factory r = main::ExtensionType|r; + static tearoff r = main::ExtensionType|_#r#tearOff; + } + static field dart.core::int ExtensionType|staticField = 42; + static inline-class-member method ExtensionType|(dart.core::int i) → main::ExtensionType /* = dart.core::int */ { + lowered final main::ExtensionType /* = dart.core::int */ #this = i; + return #this; + } + static inline-class-member method ExtensionType|_#new#tearOff(dart.core::int i) → main::ExtensionType /* = dart.core::int */ + return main::ExtensionType|(i); + static inline-class-member method ExtensionType|f(dart.core::int i) → main::ExtensionType /* = dart.core::int */ + return main::ExtensionType|(i); + static inline-class-member method ExtensionType|_#f#tearOff(dart.core::int i) → main::ExtensionType /* = dart.core::int */ + return main::ExtensionType|f(i); + static inline-class-member method ExtensionType|r(dart.core::int i) → main::ExtensionType /* = dart.core::int */ /* redirection-target: main::ExtensionType| */ + return main::ExtensionType|(i); + static inline-class-member method ExtensionType|_#r#tearOff(dart.core::int i) → main::ExtensionType /* = dart.core::int */ + return main::ExtensionType|(i); + static inline-class-member method ExtensionType|method(lowered final main::ExtensionType /* = dart.core::int */ #this) → dart.core::int + return #this as{Unchecked} dart.core::int; + static inline-class-member method ExtensionType|get#method(lowered final main::ExtensionType /* = dart.core::int */ #this) → () → dart.core::int + return () → dart.core::int => main::ExtensionType|method(#this); + static inline-class-member method ExtensionType|get#getter(lowered final main::ExtensionType /* = dart.core::int */ #this) → dart.core::int + return #this as{Unchecked} dart.core::int; + static inline-class-member method ExtensionType|set#setter(lowered final main::ExtensionType /* = dart.core::int */ #this, dart.core::int value) → void {} + static inline-class-member method ExtensionType|staticMethod() → void {} + static method main() → dynamic { + main::ExtensionType|method(main::ExtensionType|(0)); + main::ExtensionType|get#getter(main::ExtensionType|f(0)); + main::ExtensionType|set#setter(main::ExtensionType|(0), 42); + main::ExtensionType|staticMethod(); + main::ExtensionType|staticField = main::ExtensionType|staticField.{dart.core::num::+}(1){(dart.core::num) → dart.core::int}; + } +} diff --git a/pkg/front_end/testcases/incremental/extension_type_declaration.yaml.world.2.expect b/pkg/front_end/testcases/incremental/extension_type_declaration.yaml.world.2.expect new file mode 100644 index 00000000000..e25ff487fc6 --- /dev/null +++ b/pkg/front_end/testcases/incremental/extension_type_declaration.yaml.world.2.expect @@ -0,0 +1,48 @@ +main = main::main; +library from "org-dartlang-test:///main.dart" as main { + + extension type ExtensionType(dart.core::int i) { + method method = main::ExtensionType|method; + tearoff method = main::ExtensionType|get#method; + get getter = main::ExtensionType|get#getter; + static method staticMethod = main::ExtensionType|staticMethod; + static field staticField = main::ExtensionType|staticField; + set setter = main::ExtensionType|set#setter; + constructor • = main::ExtensionType|; + tearoff • = main::ExtensionType|_#new#tearOff; + static factory f = main::ExtensionType|f; + static tearoff f = main::ExtensionType|_#f#tearOff; + static redirecting-factory r = main::ExtensionType|r; + static tearoff r = main::ExtensionType|_#r#tearOff; + } + static field dart.core::int ExtensionType|staticField = 42; + static inline-class-member method ExtensionType|(dart.core::int i) → main::ExtensionType /* = dart.core::int */ { + lowered final main::ExtensionType /* = dart.core::int */ #this = i; + return #this; + } + static inline-class-member method ExtensionType|_#new#tearOff(dart.core::int i) → main::ExtensionType /* = dart.core::int */ + return main::ExtensionType|(i); + static inline-class-member method ExtensionType|f(dart.core::int i) → main::ExtensionType /* = dart.core::int */ + return main::ExtensionType|(i); + static inline-class-member method ExtensionType|_#f#tearOff(dart.core::int i) → main::ExtensionType /* = dart.core::int */ + return main::ExtensionType|f(i); + static inline-class-member method ExtensionType|r(dart.core::int i) → main::ExtensionType /* = dart.core::int */ /* redirection-target: main::ExtensionType| */ + return main::ExtensionType|(i); + static inline-class-member method ExtensionType|_#r#tearOff(dart.core::int i) → main::ExtensionType /* = dart.core::int */ + return main::ExtensionType|(i); + static inline-class-member method ExtensionType|method(lowered final main::ExtensionType /* = dart.core::int */ #this) → dart.core::int + return #this as{Unchecked} dart.core::int; + static inline-class-member method ExtensionType|get#method(lowered final main::ExtensionType /* = dart.core::int */ #this) → () → dart.core::int + return () → dart.core::int => main::ExtensionType|method(#this); + static inline-class-member method ExtensionType|get#getter(lowered final main::ExtensionType /* = dart.core::int */ #this) → dart.core::int + return #this as{Unchecked} dart.core::int; + static inline-class-member method ExtensionType|set#setter(lowered final main::ExtensionType /* = dart.core::int */ #this, dart.core::int value) → void {} + static inline-class-member method ExtensionType|staticMethod() → void {} + static method main() → dynamic { + main::ExtensionType|method(main::ExtensionType|(1)); + main::ExtensionType|get#getter(main::ExtensionType|f(1)); + main::ExtensionType|set#setter(main::ExtensionType|(1), 42); + main::ExtensionType|staticMethod(); + main::ExtensionType|staticField = main::ExtensionType|staticField.{dart.core::num::+}(2){(dart.core::num) → dart.core::int}; + } +} diff --git a/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.strong.expect b/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.strong.expect index ac457c496fe..bdc5f430b8e 100644 --- a/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.strong.expect +++ b/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.strong.expect @@ -14,11 +14,11 @@ import "dart:core" as core; part has_part_of_lib.dart; extension type C(core::int i) { // from org-dartlang-testcase:///has_part_of_lib.dart constructor • = has::C|; - tearoff • = has::_#new#tearOff; + tearoff • = has::C|_#new#tearOff; } static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C /* = core::int */ { lowered final has::C /* = core::int */ #this = i; return #this; } -static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C /* = core::int */ +static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|_#new#tearOff(core::int i) → has::C /* = core::int */ return has::C|(i); diff --git a/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.strong.transformed.expect b/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.strong.transformed.expect index ac457c496fe..bdc5f430b8e 100644 --- a/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.strong.transformed.expect @@ -14,11 +14,11 @@ import "dart:core" as core; part has_part_of_lib.dart; extension type C(core::int i) { // from org-dartlang-testcase:///has_part_of_lib.dart constructor • = has::C|; - tearoff • = has::_#new#tearOff; + tearoff • = has::C|_#new#tearOff; } static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C /* = core::int */ { lowered final has::C /* = core::int */ #this = i; return #this; } -static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C /* = core::int */ +static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|_#new#tearOff(core::int i) → has::C /* = core::int */ return has::C|(i); diff --git a/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.expect b/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.expect index ac457c496fe..bdc5f430b8e 100644 --- a/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.expect +++ b/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.expect @@ -14,11 +14,11 @@ import "dart:core" as core; part has_part_of_lib.dart; extension type C(core::int i) { // from org-dartlang-testcase:///has_part_of_lib.dart constructor • = has::C|; - tearoff • = has::_#new#tearOff; + tearoff • = has::C|_#new#tearOff; } static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C /* = core::int */ { lowered final has::C /* = core::int */ #this = i; return #this; } -static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C /* = core::int */ +static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|_#new#tearOff(core::int i) → has::C /* = core::int */ return has::C|(i); diff --git a/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.modular.expect b/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.modular.expect index ac457c496fe..bdc5f430b8e 100644 --- a/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.modular.expect +++ b/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.modular.expect @@ -14,11 +14,11 @@ import "dart:core" as core; part has_part_of_lib.dart; extension type C(core::int i) { // from org-dartlang-testcase:///has_part_of_lib.dart constructor • = has::C|; - tearoff • = has::_#new#tearOff; + tearoff • = has::C|_#new#tearOff; } static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C /* = core::int */ { lowered final has::C /* = core::int */ #this = i; return #this; } -static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C /* = core::int */ +static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|_#new#tearOff(core::int i) → has::C /* = core::int */ return has::C|(i); diff --git a/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.outline.expect b/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.outline.expect index 2814bf262e7..abbd7382b6c 100644 --- a/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.outline.expect +++ b/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.outline.expect @@ -15,9 +15,9 @@ import "dart:core" as core; part has_part_of_lib.dart; extension type C(core::int i) { // from org-dartlang-testcase:///has_part_of_lib.dart constructor • = has::C|; - tearoff • = has::_#new#tearOff; + tearoff • = has::C|_#new#tearOff; } static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C /* = core::int */ ; -static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C /* = core::int */ +static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|_#new#tearOff(core::int i) → has::C /* = core::int */ return has::C|(i); diff --git a/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.transformed.expect b/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.transformed.expect index ac457c496fe..bdc5f430b8e 100644 --- a/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/inline_class/extension_types/has_export.dart.weak.transformed.expect @@ -14,11 +14,11 @@ import "dart:core" as core; part has_part_of_lib.dart; extension type C(core::int i) { // from org-dartlang-testcase:///has_part_of_lib.dart constructor • = has::C|; - tearoff • = has::_#new#tearOff; + tearoff • = has::C|_#new#tearOff; } static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C /* = core::int */ { lowered final has::C /* = core::int */ #this = i; return #this; } -static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C /* = core::int */ +static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|_#new#tearOff(core::int i) → has::C /* = core::int */ return has::C|(i); diff --git a/pkg/front_end/testcases/inline_class/has_export.dart.strong.expect b/pkg/front_end/testcases/inline_class/has_export.dart.strong.expect index ac457c496fe..bdc5f430b8e 100644 --- a/pkg/front_end/testcases/inline_class/has_export.dart.strong.expect +++ b/pkg/front_end/testcases/inline_class/has_export.dart.strong.expect @@ -14,11 +14,11 @@ import "dart:core" as core; part has_part_of_lib.dart; extension type C(core::int i) { // from org-dartlang-testcase:///has_part_of_lib.dart constructor • = has::C|; - tearoff • = has::_#new#tearOff; + tearoff • = has::C|_#new#tearOff; } static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C /* = core::int */ { lowered final has::C /* = core::int */ #this = i; return #this; } -static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C /* = core::int */ +static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|_#new#tearOff(core::int i) → has::C /* = core::int */ return has::C|(i); diff --git a/pkg/front_end/testcases/inline_class/has_export.dart.strong.transformed.expect b/pkg/front_end/testcases/inline_class/has_export.dart.strong.transformed.expect index ac457c496fe..bdc5f430b8e 100644 --- a/pkg/front_end/testcases/inline_class/has_export.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/inline_class/has_export.dart.strong.transformed.expect @@ -14,11 +14,11 @@ import "dart:core" as core; part has_part_of_lib.dart; extension type C(core::int i) { // from org-dartlang-testcase:///has_part_of_lib.dart constructor • = has::C|; - tearoff • = has::_#new#tearOff; + tearoff • = has::C|_#new#tearOff; } static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C /* = core::int */ { lowered final has::C /* = core::int */ #this = i; return #this; } -static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C /* = core::int */ +static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|_#new#tearOff(core::int i) → has::C /* = core::int */ return has::C|(i); diff --git a/pkg/front_end/testcases/inline_class/has_export.dart.weak.expect b/pkg/front_end/testcases/inline_class/has_export.dart.weak.expect index ac457c496fe..bdc5f430b8e 100644 --- a/pkg/front_end/testcases/inline_class/has_export.dart.weak.expect +++ b/pkg/front_end/testcases/inline_class/has_export.dart.weak.expect @@ -14,11 +14,11 @@ import "dart:core" as core; part has_part_of_lib.dart; extension type C(core::int i) { // from org-dartlang-testcase:///has_part_of_lib.dart constructor • = has::C|; - tearoff • = has::_#new#tearOff; + tearoff • = has::C|_#new#tearOff; } static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C /* = core::int */ { lowered final has::C /* = core::int */ #this = i; return #this; } -static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C /* = core::int */ +static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|_#new#tearOff(core::int i) → has::C /* = core::int */ return has::C|(i); diff --git a/pkg/front_end/testcases/inline_class/has_export.dart.weak.modular.expect b/pkg/front_end/testcases/inline_class/has_export.dart.weak.modular.expect index ac457c496fe..bdc5f430b8e 100644 --- a/pkg/front_end/testcases/inline_class/has_export.dart.weak.modular.expect +++ b/pkg/front_end/testcases/inline_class/has_export.dart.weak.modular.expect @@ -14,11 +14,11 @@ import "dart:core" as core; part has_part_of_lib.dart; extension type C(core::int i) { // from org-dartlang-testcase:///has_part_of_lib.dart constructor • = has::C|; - tearoff • = has::_#new#tearOff; + tearoff • = has::C|_#new#tearOff; } static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C /* = core::int */ { lowered final has::C /* = core::int */ #this = i; return #this; } -static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C /* = core::int */ +static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|_#new#tearOff(core::int i) → has::C /* = core::int */ return has::C|(i); diff --git a/pkg/front_end/testcases/inline_class/has_export.dart.weak.outline.expect b/pkg/front_end/testcases/inline_class/has_export.dart.weak.outline.expect index 2814bf262e7..abbd7382b6c 100644 --- a/pkg/front_end/testcases/inline_class/has_export.dart.weak.outline.expect +++ b/pkg/front_end/testcases/inline_class/has_export.dart.weak.outline.expect @@ -15,9 +15,9 @@ import "dart:core" as core; part has_part_of_lib.dart; extension type C(core::int i) { // from org-dartlang-testcase:///has_part_of_lib.dart constructor • = has::C|; - tearoff • = has::_#new#tearOff; + tearoff • = has::C|_#new#tearOff; } static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C /* = core::int */ ; -static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C /* = core::int */ +static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|_#new#tearOff(core::int i) → has::C /* = core::int */ return has::C|(i); diff --git a/pkg/front_end/testcases/inline_class/has_export.dart.weak.transformed.expect b/pkg/front_end/testcases/inline_class/has_export.dart.weak.transformed.expect index ac457c496fe..bdc5f430b8e 100644 --- a/pkg/front_end/testcases/inline_class/has_export.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/inline_class/has_export.dart.weak.transformed.expect @@ -14,11 +14,11 @@ import "dart:core" as core; part has_part_of_lib.dart; extension type C(core::int i) { // from org-dartlang-testcase:///has_part_of_lib.dart constructor • = has::C|; - tearoff • = has::_#new#tearOff; + tearoff • = has::C|_#new#tearOff; } static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C /* = core::int */ { lowered final has::C /* = core::int */ #this = i; return #this; } -static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C /* = core::int */ +static inline-class-member method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|_#new#tearOff(core::int i) → has::C /* = core::int */ return has::C|(i); diff --git a/pkg/front_end/testcases/weak.status b/pkg/front_end/testcases/weak.status index 00564e4bd09..13c99ab5317 100644 --- a/pkg/front_end/testcases/weak.status +++ b/pkg/front_end/testcases/weak.status @@ -8,6 +8,7 @@ class_modifiers/issue52115/main: SemiFuzzFailure # https://github.com/dart-lang/sdk/issues/53109 class_modifiers/issue52316/main: SemiFuzzFailure # https://github.com/dart-lang/sdk/issues/53109 const_functions/const_functions_switch_statements: SemiFuzzFailure # https://github.com/dart-lang/sdk/issues/53111 +inline_class/extension_types/representation_type: SemiFuzzCrash # https://github.com/dart-lang/sdk/issues/53270 # POSSIBLY BAD ONES dart2js/issue51823: SemiFuzzFailure # Inequivalent nodes on recompile - https://github.com/dart-lang/sdk/issues/53119. @@ -33,69 +34,15 @@ patterns/switchExpression_twoPatterns: SemiFuzzFailure # textualOutline returns records/block_combine_statements: SemiFuzzFailure # textualOutline returns null on split with pattern stuff - https://github.com/dart-lang/sdk/issues/53116. records/for_in_without_variable: SemiFuzzFailure # textualOutline returns null on split with pattern stuff - https://github.com/dart-lang/sdk/issues/53116. -inline_class/const_constructor: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/extension_types/const_constructor: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/extension_types/cyclic_extension_types: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/extension_types/external: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/extension_types/field_access: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/extension_types/implements: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/extension_types/initializers: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/extension_types/issue52119: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/extension_types/issue52284: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/extension_types/member_not_found: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/extension_types/method_access: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/extension_types/representation: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/extension_types/super_extension_type_conflict: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/extension_types/supertype_conflict: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/field_access: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/implements: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/initializers: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/issue52119: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/issue52284: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/member_not_found: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/method_access: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/procedures: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. -inline_class/representation: SemiFuzzCrash # checkEquivalence crash - https://github.com/dart-lang/sdk/issues/53115. - # INCREMENTAL COMPILATION ERRORS dart2js/inline_class/external: SemiFuzzFailure # @methods::B| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. dart2js/inline_class/issue51285: SemiFuzzFailure # @methods::I| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. dartdevc/inline_class/external: SemiFuzzFailure # @methods::B| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. dartdevc/inline_class/issue51285: SemiFuzzFailure # @methods::I| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. inline_class/annotations: SemiFuzzFailure # @methods::A| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/constructor_access: SemiFuzzFailure # @methods::Class| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/constructor_bodies: SemiFuzzFailure # @methods::Class1| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. inline_class/constructor_formal_parameters: SemiFuzzFailure # @methods::I| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/constructors: SemiFuzzFailure # @methods::Class1| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/annotations: SemiFuzzFailure # @methods::A| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/constructor_access: SemiFuzzFailure # @methods::Class| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/constructor_bodies: SemiFuzzFailure # @methods::Class1| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/constructor_formal_parameters: SemiFuzzFailure # @methods::I|_ is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/constructors: SemiFuzzFailure # @methods::Class1| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/extension_type_declarations: SemiFuzzFailure # @methods::ExtensionType1| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/from_dill/main.no_link: SemiFuzzFailure # @methods::ExtensionType| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/from_dill/main: SemiFuzzFailure # @methods::ExtensionType| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/has_export: SemiFuzzFailure # https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/inline_class_declaration: SemiFuzzFailure # @methods::Class1| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/issue51146: SemiFuzzFailure # @methods::I| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/issue51285: SemiFuzzFailure # @methods::I|_ is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/issue51299: SemiFuzzFailure # @methods::I| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/issue51556: SemiFuzzFailure # @methods::JSAny| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/issue52240: SemiFuzzFailure # @methods::X|_ is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/issue52525: SemiFuzzFailure # @methods::IC1| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/issue52667: SemiFuzzFailure # @methods::FooBar| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/procedures: SemiFuzzFailure # @methods::Class|_ is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/extension_types/unresolved_type_extension_type_this: SemiFuzzFailure # https://github.com/dart-lang/sdk/issues/53117. -inline_class/external: SemiFuzzFailure # @methods::B| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/has_export: SemiFuzzFailure # https://github.com/dart-lang/sdk/issues/53117. -inline_class/inline_class_declaration: SemiFuzzFailure # @methods::Class1| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/issue51146: SemiFuzzFailure # @methods::I| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/issue51285: SemiFuzzFailure # @methods::I| is already bound to Reference to - https://github.com/dart-lang/sdk/issues/53117. +inline_class/external: SemiFuzzFailure # @methods::A| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. inline_class/issue51299: SemiFuzzFailure # @methods::I|set#i is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/issue51556: SemiFuzzFailure # @methods::JSAny| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/issue52240: SemiFuzzFailure # @methods::X| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/issue52525: SemiFuzzFailure # @methods::IC1| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. -inline_class/issue52667: SemiFuzzFailure # @methods::FooBar| is already bound to Reference - https://github.com/dart-lang/sdk/issues/53117. # EXPECTED FAILURES DUE TO PRIVACY ETC: records/issue51940: semiFuzzFailureOnForceRebuildBodies # can't split because of sealed class. diff --git a/pkg/kernel/lib/src/equivalence_helpers.dart b/pkg/kernel/lib/src/equivalence_helpers.dart index 910b3056d55..d9f9fa226a7 100644 --- a/pkg/kernel/lib/src/equivalence_helpers.dart +++ b/pkg/kernel/lib/src/equivalence_helpers.dart @@ -274,6 +274,10 @@ class ReferenceName { return new ReferenceName.internal( ReferenceNameKind.Declaration, node.name, parent: new ReferenceName.fromNamedNode(node.enclosingLibrary)); + } else if (node is ExtensionTypeDeclaration) { + return new ReferenceName.internal( + ReferenceNameKind.Declaration, node.name, + parent: new ReferenceName.fromNamedNode(node.enclosingLibrary)); } else if (node is Class) { return new ReferenceName.internal( ReferenceNameKind.Declaration, node.name,