diff --git a/pkg/kernel/analysis_options.yaml b/pkg/kernel/analysis_options.yaml index 5e69d0b657b..a5258579105 100644 --- a/pkg/kernel/analysis_options.yaml +++ b/pkg/kernel/analysis_options.yaml @@ -6,6 +6,8 @@ analyzer: linter: rules: + - unnecessary_type_name_in_constructor + - unnecessary_const_in_enum_constructor - collection_methods_unrelated_type - curly_braces_in_flow_control_structures - prefer_adjacent_string_concatenation diff --git a/pkg/kernel/bin/compare_hierarchies.dart b/pkg/kernel/bin/compare_hierarchies.dart index ae754195392..8c8ef1276ec 100644 --- a/pkg/kernel/bin/compare_hierarchies.dart +++ b/pkg/kernel/bin/compare_hierarchies.dart @@ -161,7 +161,7 @@ class ClassReference { final String name; final Uri libImportUri; - const ClassReference(this.name, this.libImportUri); + const new(this.name, this.libImportUri); @override int get hashCode => name.hashCode * 13 + libImportUri.hashCode * 17; diff --git a/pkg/kernel/bin/size_breakdown.dart b/pkg/kernel/bin/size_breakdown.dart index 31801f939a3..aa4cf2bd340 100755 --- a/pkg/kernel/bin/size_breakdown.dart +++ b/pkg/kernel/bin/size_breakdown.dart @@ -38,7 +38,7 @@ void main(args) { } class WrappedBinaryBuilder extends BinaryBuilder { - WrappedBinaryBuilder(_bytes) : super(_bytes, disableLazyReading: true); + new(_bytes) : super(_bytes, disableLazyReading: true); int offsetsSize = 0; int stringTableSize = 0; int linkTableSize = 0; diff --git a/pkg/kernel/bin/switch_order.dart b/pkg/kernel/bin/switch_order.dart index 77461df1da8..89f982f509c 100755 --- a/pkg/kernel/bin/switch_order.dart +++ b/pkg/kernel/bin/switch_order.dart @@ -120,7 +120,7 @@ class SortableDataString implements Comparable { final double data; final String value; - SortableDataString(this.data, this.value); + new(this.data, this.value); @override String toString() => value; @@ -158,7 +158,7 @@ class WrappedBinaryBuilder extends BinaryBuilder { List statementTypes = List.filled(255, 0); List typeTypes = List.filled(255, 0); - WrappedBinaryBuilder(_bytes) + new(_bytes) : super( _bytes, disableLazyReading: true, diff --git a/pkg/kernel/lib/binary/ast_from_binary.dart b/pkg/kernel/lib/binary/ast_from_binary.dart index 8342eae5cc9..9521e184da5 100644 --- a/pkg/kernel/lib/binary/ast_from_binary.dart +++ b/pkg/kernel/lib/binary/ast_from_binary.dart @@ -20,7 +20,7 @@ class ParseError { final String message; final String path; - ParseError( + new( this.message, { required this.filename, required this.byteIndex, @@ -35,7 +35,7 @@ class InvalidKernelVersionError { final String? filename; final int version; - InvalidKernelVersionError(this.filename, this.version); + new(this.filename, this.version); @override String toString() { @@ -54,7 +54,7 @@ class InvalidKernelVersionError { class InvalidKernelSdkVersionError { final String version; - InvalidKernelSdkVersionError(this.version); + new(this.version); @override String toString() { @@ -66,7 +66,7 @@ class InvalidKernelSdkVersionError { class CompilationModeError { final String message; - CompilationModeError(this.message); + new(this.message); @override String toString() => "CompilationModeError[$message]"; @@ -86,7 +86,7 @@ class _ComponentIndex { final int libraryCount; final int componentFileSizeInBytes; - _ComponentIndex({ + new({ required this.binaryOffsetForSourceTable, required this.binaryOffsetForCanonicalNames, required this.binaryOffsetForMetadataPayloads, @@ -107,11 +107,7 @@ class SubComponentView { final int componentStartOffset; final int componentFileSize; - SubComponentView( - this.libraries, - this.componentStartOffset, - this.componentFileSize, - ); + new(this.libraries, this.componentStartOffset, this.componentFileSize); } /// [StringInterner] allows Strings created from the binary to be shared with @@ -184,7 +180,7 @@ class BinaryBuilder { /// Note that [disableLazyClassReading] is incompatible /// with checkCanonicalNames on readComponent. - BinaryBuilder( + new( this._bytes, { this.filename, bool disableLazyReading = false, @@ -4585,7 +4581,7 @@ class BinaryBuilderWithMetadata extends BinaryBuilder implements BinarySource { List? _allKnownMetadataKeys; int? _previousMetadataLookupKey; - BinaryBuilderWithMetadata( + new( Uint8List bytes, { String? filename, bool disableLazyReading = false, @@ -4927,5 +4923,5 @@ class _MetadataSubsection { /// Deserialized mapping from node offsets to metadata offsets. final Map mapping; - _MetadataSubsection(this.repository, this.mapping); + new(this.repository, this.mapping); } diff --git a/pkg/kernel/lib/binary/ast_to_binary.dart b/pkg/kernel/lib/binary/ast_to_binary.dart index 3793de24983..744c43d7637 100644 --- a/pkg/kernel/lib/binary/ast_to_binary.dart +++ b/pkg/kernel/lib/binary/ast_to_binary.dart @@ -66,7 +66,7 @@ class BinaryPrinter /// /// The BinaryPrinter will use its own buffer, so the [sink] does not need /// one. - BinaryPrinter( + new( Sink> sink, { this.libraryFilter, StringIndexer? stringIndexer, @@ -3608,7 +3608,7 @@ class StringIndexer { // Note that the iteration order is important. final Map index = new Map(); - StringIndexer() { + new() { put(''); } @@ -3626,7 +3626,7 @@ class UriIndexer { // Note that the iteration order is important. final Map index = new Map(); - UriIndexer(); + new(); int put(Uri uri) { int? result = index[uri]; @@ -3653,7 +3653,7 @@ class BufferedSink { int get offset => length + flushedLength; - BufferedSink(this._sink); + new(this._sink); void addDouble(double d) { Uint8List doubleBufferUint8 = _doubleBufferUint8 ??= _doubleBuffer.buffer @@ -3758,7 +3758,7 @@ class _MetadataSubsection { /// (nodeOffset) in ascending order. final List metadataMapping = []; - _MetadataSubsection(this.repository); + new(this.repository); } /// A [Sink] that directly writes data into a byte builder. diff --git a/pkg/kernel/lib/binary/multi_binary_loader.dart b/pkg/kernel/lib/binary/multi_binary_loader.dart index 91a79f10404..51c8a3c5f80 100644 --- a/pkg/kernel/lib/binary/multi_binary_loader.dart +++ b/pkg/kernel/lib/binary/multi_binary_loader.dart @@ -166,7 +166,7 @@ class _LoadedData { final Component component; final List linkTable; - _LoadedData(this.data, this.component, this.linkTable); + new(this.data, this.component, this.linkTable); } /// Calculate the "Adler-32" checksum. diff --git a/pkg/kernel/lib/canonical_name.dart b/pkg/kernel/lib/canonical_name.dart index 19a57866d16..cea7fd60374 100644 --- a/pkg/kernel/lib/canonical_name.dart +++ b/pkg/kernel/lib/canonical_name.dart @@ -93,11 +93,11 @@ class CanonicalName implements Comparable { /// Temporary index used during serialization. int index = -1; - CanonicalName._(CanonicalName parent, this.name) : _parent = parent { + new _(CanonicalName parent, this.name) : _parent = parent { _nonRootTop = parent.isRoot ? this : parent._nonRootTop; } - CanonicalName.root() : _parent = null, _nonRootTop = null, name = ''; + new root() : _parent = null, _nonRootTop = null, name = ''; bool get isRoot => _parent == null; @@ -672,14 +672,14 @@ class Reference implements Comparable { class CanonicalNameError { final String message; - CanonicalNameError(this.message); + new(this.message); @override String toString() => 'CanonicalNameError: $message'; } class CanonicalNameSdkError extends CanonicalNameError { - CanonicalNameSdkError(String message) : super(message); + new(String message) : super(message); @override String toString() => 'CanonicalNameSdkError: $message'; diff --git a/pkg/kernel/lib/class_hierarchy.dart b/pkg/kernel/lib/class_hierarchy.dart index 863bec66526..d0337941c78 100644 --- a/pkg/kernel/lib/class_hierarchy.dart +++ b/pkg/kernel/lib/class_hierarchy.dart @@ -372,7 +372,7 @@ abstract class ClassHierarchyMembers { /// Interface for answering various subclassing queries. abstract class ClassHierarchy implements ClassHierarchyBase, ClassHierarchyMembers { - factory ClassHierarchy( + factory( Component component, CoreTypes coreTypes, { HandleAmbiguousSupertypes? onAmbiguousSupertypes, @@ -634,7 +634,7 @@ class _ClassInfoSubtype { /// interleaved begin/end interval end points. late final Uint32List subtypeIntervalList; - _ClassInfoSubtype(this.classInfo); + new(this.classInfo); } class _ClosedWorldClassHierarchySubtypes implements ClassHierarchySubtypes { @@ -643,7 +643,7 @@ class _ClosedWorldClassHierarchySubtypes implements ClassHierarchySubtypes { final Map _infoMap = {}; bool invalidated = false; - _ClosedWorldClassHierarchySubtypes(this.hierarchy) + new(this.hierarchy) : _classesByTopDownIndex = new List.filled( hierarchy._infoMap.length, null, @@ -814,7 +814,7 @@ class ClosedWorldClassHierarchy _ClosedWorldClassHierarchySubtypes? _cachedClassHierarchySubtypes; - ClosedWorldClassHierarchy._internal( + new _internal( this.coreTypes, HandleAmbiguousSupertypes onAmbiguousSupertypes, ) { @@ -2067,7 +2067,7 @@ class ForTestingClassInfo { final List? lazyInterfaceGettersAndCalls; final List? lazyInterfaceSetters; - ForTestingClassInfo._(_ClassInfo c) + new _(_ClassInfo c) : classNode = c.classNode, lazyDeclaredGettersAndCalls = c.lazyDeclaredGettersAndCalls, lazyDeclaredSetters = c.lazyDeclaredSetters, @@ -2135,7 +2135,7 @@ class _ClassInfo { List? lazyInterfaceGettersAndCalls; List? lazyInterfaceSetters; - _ClassInfo(this.classNode); + new(this.classNode); bool isSubclassOf(_ClassInfo other) { return _intervalListContains( @@ -2187,7 +2187,7 @@ class _ClassInfo { /// An immutable set of classes. class ClassSet extends IterableBase { final Set _classes; - ClassSet(this._classes); + new(this._classes); @override bool contains(Object? class_) { diff --git a/pkg/kernel/lib/clone.dart b/pkg/kernel/lib/clone.dart index 0e4976a8df3..69afd22b54b 100644 --- a/pkg/kernel/lib/clone.dart +++ b/pkg/kernel/lib/clone.dart @@ -31,7 +31,7 @@ class CloneVisitorNotMembers /// The boolean value of [cloneAnnotations] tells if the annotations on the /// outline elements in the source AST should be cloned to the target AST. The /// annotations in procedure bodies are cloned unconditionally. - CloneVisitorNotMembers({ + new({ Map? typeSubstitution, Map? typeParams, Map? structuralParameters, @@ -1389,7 +1389,7 @@ class CloneVisitorNotMembers /// It is safe to clone members, but cloning a class or library is not /// supported. class CloneVisitorWithMembers extends CloneVisitorNotMembers { - CloneVisitorWithMembers({ + new({ Map? typeSubstitution, Map? typeParams, bool cloneAnnotations = true, @@ -1522,7 +1522,7 @@ class MixinApplicationCloner extends CloneVisitorWithMembers { Map? _getterMap; Map? _setterMap; - MixinApplicationCloner( + new( this.mixinApplicationClass, { Map? typeSubstitution, Map? typeParams, @@ -1617,7 +1617,7 @@ class MixinApplicationCloner extends CloneVisitorWithMembers { } class CloneProcedureWithoutBody extends CloneVisitorWithMembers { - CloneProcedureWithoutBody({ + new({ Map? typeSubstitution, bool cloneAnnotations = true, }) : super( diff --git a/pkg/kernel/lib/const_finder.dart b/pkg/kernel/lib/const_finder.dart index 7d223727426..6a6576adac9 100644 --- a/pkg/kernel/lib/const_finder.dart +++ b/pkg/kernel/lib/const_finder.dart @@ -7,7 +7,7 @@ import 'dart:collection'; import 'kernel.dart'; class _ConstVisitor extends RecursiveVisitor { - _ConstVisitor( + new( this.classLibraryUri, this.className, this.annotationClassLibraryUri, @@ -187,7 +187,7 @@ class ConstFinder { /// Creates a new ConstFinder class. /// /// The `kernelFilePath` is the path to a dill (kernel) file to process. - ConstFinder({ + new({ required this.kernelFilePath, required String classLibraryUri, required String className, diff --git a/pkg/kernel/lib/core_types.dart b/pkg/kernel/lib/core_types.dart index 7cdb066b3e4..65b8d1ce68d 100644 --- a/pkg/kernel/lib/core_types.dart +++ b/pkg/kernel/lib/core_types.dart @@ -95,8 +95,7 @@ class CoreTypes { final Map _bottomInterfaceTypes = new Map.identity(); - CoreTypes(Component component) - : index = new LibraryIndex.coreLibraries(component); + new(Component component) : index = new LibraryIndex.coreLibraries(component); late final Library asyncLibrary = index.getLibrary('dart:async'); diff --git a/pkg/kernel/lib/error_formatter.dart b/pkg/kernel/lib/error_formatter.dart index 5d2cc2059a9..f41a12675d3 100644 --- a/pkg/kernel/lib/error_formatter.dart +++ b/pkg/kernel/lib/error_formatter.dart @@ -137,7 +137,7 @@ Source: class HighlightingPrinter extends Printer { final Node highlight; - HighlightingPrinter(this.highlight) + new(this.highlight) : super(new StringBuffer(), syntheticNames: globalDebuggingNames); @override diff --git a/pkg/kernel/lib/extension_table.dart b/pkg/kernel/lib/extension_table.dart index fbb2deb3a2a..f69662115a5 100644 --- a/pkg/kernel/lib/extension_table.dart +++ b/pkg/kernel/lib/extension_table.dart @@ -47,7 +47,7 @@ class ExtensionMemberInfo { /// The [ExtensionMemberDescriptor] for the lowered [member]. final ExtensionMemberDescriptor descriptor; - ExtensionMemberInfo(this.extension, this.member, this.descriptor); + new(this.extension, this.member, this.descriptor); } /// Information about an extension type member lowered as a top level member. @@ -61,11 +61,7 @@ class ExtensionTypeMemberInfo { /// The [ExtensionMemberDescriptor] for the lowered [member]. final ExtensionTypeMemberDescriptor descriptor; - ExtensionTypeMemberInfo( - this.extensionTypeDeclaration, - this.member, - this.descriptor, - ); + new(this.extensionTypeDeclaration, this.member, this.descriptor); } class _LibraryInfo { @@ -75,7 +71,7 @@ class _LibraryInfo { _library, ); - _LibraryInfo(this._library); + new(this._library); ExtensionMemberInfo getExtensionMemberInfo(Member member) { return _extensionTable[member]; @@ -89,7 +85,7 @@ class _LibraryInfo { class _ExtensionTable { final Map _map = {}; - _ExtensionTable(Library library) { + new(Library library) { for (Extension extension in library.extensions) { for (ExtensionMemberDescriptor descriptor in extension.memberDescriptors) { @@ -119,7 +115,7 @@ class _ExtensionTable { class _ExtensionTypeTable { final Map _map = {}; - _ExtensionTypeTable(Library library) { + new(Library library) { for (ExtensionTypeDeclaration extensionTypeDeclaration in library.extensionTypeDeclarations) { for (ExtensionTypeMemberDescriptor descriptor diff --git a/pkg/kernel/lib/import_table.dart b/pkg/kernel/lib/import_table.dart index 0698253e728..cf89ee21650 100644 --- a/pkg/kernel/lib/import_table.dart +++ b/pkg/kernel/lib/import_table.dart @@ -13,7 +13,7 @@ abstract class ImportTable { class ComponentImportTable implements ImportTable { final Map _libraryIndex = {}; - ComponentImportTable(Component component) { + new(Component component) { for (int i = 0; i < component.libraries.length; ++i) { _libraryIndex[component.libraries[i]] = i; } @@ -28,11 +28,11 @@ class LibraryImportTable implements ImportTable { final List _importedLibraries = []; final Map _libraryIndex = {}; - factory LibraryImportTable(Library lib) { + factory(Library lib) { return new _ImportTableBuilder(lib).build(); } - LibraryImportTable.empty(); + new empty(); List get importedLibraries => _importedLibraries; @@ -67,7 +67,7 @@ class _ImportTableBuilder extends RecursiveVisitor { return table; } - _ImportTableBuilder(this.referenceLibrary) { + new(this.referenceLibrary) { table.addImport(referenceLibrary, ''); } diff --git a/pkg/kernel/lib/library_index.dart b/pkg/kernel/lib/library_index.dart index a66069d82fc..a5d84181cbd 100644 --- a/pkg/kernel/lib/library_index.dart +++ b/pkg/kernel/lib/library_index.dart @@ -23,14 +23,11 @@ class LibraryIndex { final Map _libraries = {}; /// Indexes the libraries with the URIs given in [libraryUris]. - LibraryIndex(Component component, Iterable libraryUris) + new(Component component, Iterable libraryUris) : this.fromLibraries(component.libraries, libraryUris); /// Indexes the libraries with the URIs given in [libraryUris]. - LibraryIndex.fromLibraries( - Iterable libraries, - Iterable libraryUris, - ) { + new fromLibraries(Iterable libraries, Iterable libraryUris) { Set libraryUriSet = libraryUris.toSet(); for (Library library in libraries) { String uri = '${library.importUri}'; @@ -41,7 +38,7 @@ class LibraryIndex { } /// Indexes `dart:` libraries. - LibraryIndex.coreLibraries(Component component) { + new coreLibraries(Component component) { for (Library library in component.libraries) { if (library.importUri.isScheme('dart')) { _libraries['${library.importUri}'] = new _ContainerTable(library); @@ -53,7 +50,7 @@ class LibraryIndex { /// /// Consider using another constructor to only index the libraries that /// are needed. - LibraryIndex.all(Component component) { + new all(Component component) { for (Library library in component.libraries) { _libraries['${library.importUri}'] = new _ContainerTable(library); } @@ -180,7 +177,7 @@ class _ContainerTable { Map? _containers; - _ContainerTable(this.library); + new(this.library); Map get containers { if (_containers == null) { @@ -279,18 +276,16 @@ class _MemberTable { Library get library => parent.library; - _MemberTable.fromClass(this.parent, this.class_) + new fromClass(this.parent, this.class_) : extensionTypeDeclaration = null, extension_ = null; - _MemberTable.fromExtensionTypeDeclaration( - this.parent, - this.extensionTypeDeclaration, - ) : class_ = null, + new fromExtensionTypeDeclaration(this.parent, this.extensionTypeDeclaration) + : class_ = null, extension_ = null; - _MemberTable.fromExtension(this.parent, this.extension_) + new fromExtension(this.parent, this.extension_) : class_ = null, extensionTypeDeclaration = null; - _MemberTable.topLevel(this.parent) + new topLevel(this.parent) : class_ = null, extensionTypeDeclaration = null, extension_ = null; diff --git a/pkg/kernel/lib/naive_type_checker.dart b/pkg/kernel/lib/naive_type_checker.dart index afd85d5ffde..8682fb88d0b 100644 --- a/pkg/kernel/lib/naive_type_checker.dart +++ b/pkg/kernel/lib/naive_type_checker.dart @@ -17,7 +17,7 @@ abstract class FailureListener { class NaiveTypeChecker extends type_checker.TypeChecker { final FailureListener failures; - factory NaiveTypeChecker( + factory( FailureListener failures, Component component, { bool ignoreSdk = false, @@ -37,7 +37,7 @@ class NaiveTypeChecker extends type_checker.TypeChecker { ); } - NaiveTypeChecker._( + new _( this.failures, CoreTypes coreTypes, ClassHierarchy hierarchy, diff --git a/pkg/kernel/lib/reference_from_index.dart b/pkg/kernel/lib/reference_from_index.dart index 3d2e54fcf96..f8de9b089aa 100644 --- a/pkg/kernel/lib/reference_from_index.dart +++ b/pkg/kernel/lib/reference_from_index.dart @@ -115,7 +115,7 @@ class IndexedLibrary extends IndexedContainerImpl { /// TODO(jensj): Should this class be renamed to make it more immediately /// clear that it also clears canonical names? And should the class be moved /// as it is more tightly bound with the incremental compiler? - IndexedLibrary(this.library) { + new(this.library) { library.reference.canonicalName = null; for (int i = 0; i < library.typedefs.length; i++) { Typedef typedef = library.typedefs[i]; @@ -179,7 +179,7 @@ class IndexedClass extends IndexedContainerImpl { @override final Library library; - IndexedClass._(this._cls, this.library) { + new _(this._cls, this.library) { for (int i = 0; i < _cls.constructors.length; i++) { Constructor constructor = _cls.constructors[i]; constructor.reference.canonicalName = null; @@ -210,10 +210,7 @@ class IndexedExtensionTypeDeclaration final IndexedLibrary _indexedLibrary; final ExtensionTypeDeclaration extensionTypeDeclaration; - IndexedExtensionTypeDeclaration( - this._indexedLibrary, - this.extensionTypeDeclaration, - ) { + new(this._indexedLibrary, this.extensionTypeDeclaration) { _addProcedures(extensionTypeDeclaration.procedures); } diff --git a/pkg/kernel/lib/src/ast/components.dart b/pkg/kernel/lib/src/ast/components.dart index cd6cd5281f4..b5af1a88b48 100644 --- a/pkg/kernel/lib/src/ast/components.dart +++ b/pkg/kernel/lib/src/ast/components.dart @@ -34,7 +34,7 @@ class Component extends TreeNode { Reference? _mainMethodName; Reference? get mainMethodName => _mainMethodName; - Component({ + new({ CanonicalName? nameRoot, List? libraries, Map? uriToSource, @@ -195,7 +195,7 @@ class Location { final int line; // 1-based. final int column; // 1-based. - Location(this.file, this.line, this.column); + new(this.file, this.line, this.column); @override String toString() => '$file:$line:$column'; @@ -216,9 +216,9 @@ class Source { String? cachedText; - Source(this.lineStarts, this.source, this.importUri, this.fileUri); + new(this.lineStarts, this.source, this.importUri, this.fileUri); - Source.emptySource(this.lineStarts, this.importUri, this.fileUri) + new emptySource(this.lineStarts, this.importUri, this.fileUri) : source = _emptySource; /// Return the text corresponding to [line] which is a 1-based line diff --git a/pkg/kernel/lib/src/ast/constants.dart b/pkg/kernel/lib/src/ast/constants.dart index 8716911f980..90a1442478b 100644 --- a/pkg/kernel/lib/src/ast/constants.dart +++ b/pkg/kernel/lib/src/ast/constants.dart @@ -80,7 +80,7 @@ abstract class AuxiliaryConstant extends Constant { sealed class PrimitiveConstant extends Constant { final T value; - PrimitiveConstant(this.value); + new(this.value); @override int get hashCode => value.hashCode; @@ -96,7 +96,7 @@ sealed class PrimitiveConstant extends Constant { } class NullConstant extends PrimitiveConstant { - NullConstant() : super(null); + new() : super(null); @override void visitChildren(Visitor v) {} @@ -124,7 +124,7 @@ class NullConstant extends PrimitiveConstant { } class BoolConstant extends PrimitiveConstant { - BoolConstant(bool value) : super(value); + new(bool value) : super(value); @override void visitChildren(Visitor v) {} @@ -154,7 +154,7 @@ class BoolConstant extends PrimitiveConstant { /// An integer constant on a non-JS target. class IntConstant extends PrimitiveConstant { - IntConstant(int value) : super(value); + new(int value) : super(value); @override void visitChildren(Visitor v) {} @@ -184,7 +184,7 @@ class IntConstant extends PrimitiveConstant { /// A double constant on a non-JS target or any numeric constant on a JS target. class DoubleConstant extends PrimitiveConstant { - DoubleConstant(double value) : super(value); + new(double value) : super(value); @override void visitChildren(Visitor v) {} @@ -220,7 +220,7 @@ class DoubleConstant extends PrimitiveConstant { } class StringConstant extends PrimitiveConstant { - StringConstant(String value) : super(value); + new(String value) : super(value); @override void visitChildren(Visitor v) {} @@ -259,7 +259,7 @@ class SymbolConstant extends Constant { final String name; final Reference? libraryReference; - SymbolConstant(this.name, this.libraryReference); + new(this.name, this.libraryReference); @override void visitChildren(Visitor v) {} @@ -312,7 +312,7 @@ class MapConstant extends Constant { final DartType valueType; final List entries; - MapConstant(this.keyType, this.valueType, this.entries); + new(this.keyType, this.valueType, this.entries); @override void visitChildren(Visitor v) { @@ -381,7 +381,7 @@ class MapConstant extends Constant { class ConstantMapEntry { final Constant key; final Constant value; - ConstantMapEntry(this.key, this.value); + new(this.key, this.value); @override String toString() => 'ConstantMapEntry(${toStringInternal()})'; @@ -412,7 +412,7 @@ class ListConstant extends Constant { final DartType typeArgument; final List entries; - ListConstant(this.typeArgument, this.entries); + new(this.typeArgument, this.entries); @override void visitChildren(Visitor v) { @@ -476,7 +476,7 @@ class SetConstant extends Constant { final DartType typeArgument; final List entries; - SetConstant(this.typeArgument, this.entries); + new(this.typeArgument, this.entries); @override void visitChildren(Visitor v) { @@ -563,7 +563,7 @@ class RecordConstant extends Constant { /// } final RecordType recordType; - RecordConstant(this.positional, this.named, this.recordType) + new(this.positional, this.named, this.recordType) : assert( positional.length == recordType.positional.length && named.length == recordType.named.length && @@ -585,7 +585,7 @@ class RecordConstant extends Constant { "${named.keys.join(", ")}", ); - RecordConstant.fromTypeContext( + new fromTypeContext( this.positional, this.named, StaticTypeContext staticTypeContext, @@ -677,7 +677,7 @@ class InstanceConstant extends Constant { final List typeArguments; final Map fieldValues; - InstanceConstant(this.classReference, this.typeArguments, this.fieldValues); + new(this.classReference, this.typeArguments, this.fieldValues); Class get classNode => classReference.asClass; @@ -753,7 +753,7 @@ class InstantiationConstant extends Constant { final Constant tearOffConstant; final List types; - InstantiationConstant(this.tearOffConstant, this.types); + new(this.tearOffConstant, this.types); @override void visitChildren(Visitor v) { @@ -815,7 +815,7 @@ class StaticTearOffConstant extends Constant implements TearOffConstant { @override final Reference targetReference; - StaticTearOffConstant(Procedure target) + new(Procedure target) : assert(target.isStatic), assert( target.kind == ProcedureKind.Method, @@ -823,7 +823,7 @@ class StaticTearOffConstant extends Constant implements TearOffConstant { ), targetReference = target.reference; - StaticTearOffConstant.byReference(this.targetReference); + new byReference(this.targetReference); @override Procedure get target => targetReference.asProcedure; @@ -878,14 +878,14 @@ class ConstructorTearOffConstant extends Constant implements TearOffConstant { @override final Reference targetReference; - ConstructorTearOffConstant(Member target) + new(Member target) : assert( target is Constructor || (target is Procedure && target.isFactory), "Unexpected constructor tear off target: $target", ), this.targetReference = getNonNullableMemberReferenceGetter(target); - ConstructorTearOffConstant.byReference(this.targetReference); + new byReference(this.targetReference); @override Member get target => targetReference.asMember; @@ -941,11 +941,11 @@ class RedirectingFactoryTearOffConstant extends Constant @override final Reference targetReference; - RedirectingFactoryTearOffConstant(Procedure target) + new(Procedure target) : assert(target.isRedirectingFactory), this.targetReference = getNonNullableMemberReferenceGetter(target); - RedirectingFactoryTearOffConstant.byReference(this.targetReference); + new byReference(this.targetReference); @override Procedure get target => targetReference.asProcedure; @@ -1006,7 +1006,7 @@ class TypedefTearOffConstant extends Constant { @override late final int hashCode = _computeHashCode(); - TypedefTearOffConstant(this.parameters, this.tearOffConstant, this.types); + new(this.parameters, this.tearOffConstant, this.types); @override void visitChildren(Visitor v) { @@ -1107,7 +1107,7 @@ class TypedefTearOffConstant extends Constant { class TypeLiteralConstant extends Constant { final DartType type; - TypeLiteralConstant(this.type); + new(this.type); @override void visitChildren(Visitor v) { @@ -1153,7 +1153,7 @@ class TypeLiteralConstant extends Constant { class UnevaluatedConstant extends Constant { final Expression expression; - UnevaluatedConstant(this.expression) { + new(this.expression) { expression.parent = null; } diff --git a/pkg/kernel/lib/src/ast/declarations.dart b/pkg/kernel/lib/src/ast/declarations.dart index 45ed2ebc110..e7525374688 100644 --- a/pkg/kernel/lib/src/ast/declarations.dart +++ b/pkg/kernel/lib/src/ast/declarations.dart @@ -321,7 +321,7 @@ class Class extends NamedNode implements TypeDeclaration { _proceduresView = null; } - Class({ + new({ required this.name, bool isAbstract = false, bool isAnonymousMixin = false, @@ -659,7 +659,7 @@ class Extension extends NamedNode node.parent = this; } - Extension({ + new({ required this.name, List? typeParameters, DartType? onType, @@ -789,7 +789,7 @@ class ExtensionMemberDescriptor { /// off, if any. final Reference? tearOffReference; - ExtensionMemberDescriptor({ + new({ required this.name, required this.kind, bool isStatic = false, @@ -900,7 +900,7 @@ class ExtensionTypeDeclaration extends NamedNode implements TypeDeclaration { node.parent = this; } - ExtensionTypeDeclaration({ + new({ required this.name, List? typeParameters, DartType? declaredRepresentationType, @@ -1104,7 +1104,7 @@ class ExtensionTypeMemberDescriptor { /// declaration member tear off, if any. final Reference? tearOffReference; - ExtensionTypeMemberDescriptor({ + new({ required this.name, required this.kind, bool isStatic = false, diff --git a/pkg/kernel/lib/src/ast/expressions.dart b/pkg/kernel/lib/src/ast/expressions.dart index a7569d8f12c..d2a4f164065 100644 --- a/pkg/kernel/lib/src/ast/expressions.dart +++ b/pkg/kernel/lib/src/ast/expressions.dart @@ -143,7 +143,7 @@ class InvalidExpression extends Expression { /// The expression containing the error. Expression? expression; - InvalidExpression(this.message, [this.expression]) { + new(this.message, [this.expression]) { expression?.parent = this; } @@ -207,7 +207,7 @@ class VariableGet extends Expression { /// Null if not promoted. DartType? promotedType; - VariableGet(this.variable, [this.promotedType]); + new(this.variable, [this.promotedType]); @override DartType getStaticType(StaticTypeContext context) => @@ -274,7 +274,7 @@ class VariableSet extends Expression { Expression value; - VariableSet(this.variable, this.value) { + new(this.variable, this.value) { value.parent = this; } @@ -328,7 +328,7 @@ class RecordIndexGet extends Expression { RecordType receiverType; final int index; - RecordIndexGet(this.receiver, this.receiverType, this.index) + new(this.receiver, this.receiverType, this.index) : assert(0 <= index && index < receiverType.positional.length) { receiver.parent = this; } @@ -386,7 +386,7 @@ class RecordNameGet extends Expression { RecordType receiverType; final String name; - RecordNameGet(this.receiver, this.receiverType, this.name) + new(this.receiver, this.receiverType, this.name) : assert( receiverType.named .singleWhere((element) => element.name == name) @@ -488,7 +488,7 @@ class DynamicGet extends Expression { Expression receiver; Name name; - DynamicGet(this.kind, this.receiver, this.name) { + new(this.kind, this.receiver, this.name) { receiver.parent = this; } @@ -572,7 +572,7 @@ class InstanceGet extends Expression { Reference interfaceTargetReference; - InstanceGet( + new( InstanceAccessKind kind, Expression receiver, Name name, { @@ -588,7 +588,7 @@ class InstanceGet extends Expression { resultType: resultType, ); - InstanceGet.byReference( + new byReference( this.kind, this.receiver, this.name, { @@ -657,7 +657,7 @@ class InstanceGet extends Expression { class FunctionTearOff extends Expression { Expression receiver; - FunctionTearOff(this.receiver) { + new(this.receiver) { receiver.parent = this; } @@ -730,7 +730,7 @@ class InstanceTearOff extends Expression { Reference interfaceTargetReference; - InstanceTearOff( + new( InstanceAccessKind kind, Expression receiver, Name name, { @@ -746,7 +746,7 @@ class InstanceTearOff extends Expression { resultType: resultType, ); - InstanceTearOff.byReference( + new byReference( this.kind, this.receiver, this.name, { @@ -816,7 +816,7 @@ class DynamicSet extends Expression { Name name; Expression value; - DynamicSet(this.kind, this.receiver, this.name, this.value) { + new(this.kind, this.receiver, this.name, this.value) { receiver.parent = this; value.parent = this; } @@ -885,7 +885,7 @@ class InstanceSet extends Expression { Reference interfaceTargetReference; - InstanceSet( + new( InstanceAccessKind kind, Expression receiver, Name name, @@ -901,7 +901,7 @@ class InstanceSet extends Expression { ), ); - InstanceSet.byReference( + new byReference( this.kind, this.receiver, this.name, @@ -1004,21 +1004,14 @@ class AbstractSuperPropertyGet extends Expression { Reference interfaceTargetReference; - AbstractSuperPropertyGet( - Expression receiver, - Name name, - Member interfaceTarget, - ) : this.byReference( + new(Expression receiver, Name name, Member interfaceTarget) + : this.byReference( receiver, name, getNonNullableMemberReferenceGetter(interfaceTarget), ); - AbstractSuperPropertyGet.byReference( - this.receiver, - this.name, - this.interfaceTargetReference, - ) { + new byReference(this.receiver, this.name, this.interfaceTargetReference) { receiver.parent = this; } @@ -1090,18 +1083,14 @@ class SuperPropertyGet extends Expression { Reference interfaceTargetReference; - SuperPropertyGet(Expression receiver, Name name, Member interfaceTarget) + new(Expression receiver, Name name, Member interfaceTarget) : this.byReference( receiver, name, getNonNullableMemberReferenceGetter(interfaceTarget), ); - SuperPropertyGet.byReference( - this.receiver, - this.name, - this.interfaceTargetReference, - ) { + new byReference(this.receiver, this.name, this.interfaceTargetReference) { receiver.parent = this; } @@ -1196,19 +1185,15 @@ class AbstractSuperPropertySet extends Expression { Reference interfaceTargetReference; - AbstractSuperPropertySet( - Expression receiver, - Name name, - Expression value, - Member interfaceTarget, - ) : this.byReference( + new(Expression receiver, Name name, Expression value, Member interfaceTarget) + : this.byReference( receiver, name, value, getNonNullableMemberReferenceSetter(interfaceTarget), ); - AbstractSuperPropertySet.byReference( + new byReference( this.receiver, this.name, this.value, @@ -1285,19 +1270,15 @@ class SuperPropertySet extends Expression { Reference interfaceTargetReference; - SuperPropertySet( - Expression receiver, - Name name, - Expression value, - Member interfaceTarget, - ) : this.byReference( + new(Expression receiver, Name name, Expression value, Member interfaceTarget) + : this.byReference( receiver, name, value, getNonNullableMemberReferenceSetter(interfaceTarget), ); - SuperPropertySet.byReference( + new byReference( this.receiver, this.name, this.value, @@ -1367,11 +1348,11 @@ class StaticGet extends Expression { /// A static field, getter, or method (for tear-off). Reference targetReference; - StaticGet(Member target) + new(Member target) : assert(target is Field || (target is Procedure && target.isGetter)), this.targetReference = getNonNullableMemberReferenceGetter(target); - StaticGet.byReference(this.targetReference); + new byReference(this.targetReference); Member get target => targetReference.asMember; @@ -1416,7 +1397,7 @@ class StaticGet extends Expression { class StaticTearOff extends Expression { Reference targetReference; - StaticTearOff(Procedure target) + new(Procedure target) : assert(target.isStatic, "Unexpected static tear off target: $target"), assert( target.kind == ProcedureKind.Method, @@ -1424,7 +1405,7 @@ class StaticTearOff extends Expression { ), this.targetReference = getNonNullableMemberReferenceGetter(target); - StaticTearOff.byReference(this.targetReference); + new byReference(this.targetReference); Procedure get target => targetReference.asProcedure; @@ -1473,10 +1454,10 @@ class StaticSet extends Expression { Reference targetReference; Expression value; - StaticSet(Member target, Expression value) + new(Member target, Expression value) : this.byReference(getNonNullableMemberReferenceSetter(target), value); - StaticSet.byReference(this.targetReference, this.value) { + new byReference(this.targetReference, this.value) { value.parent = this; } @@ -1535,22 +1516,19 @@ class Arguments extends TreeNode { final List positional; List named; - Arguments( - this.positional, { - List? types, - List? named, - }) : this.types = types ?? [], - this.named = named ?? [] { + new(this.positional, {List? types, List? named}) + : this.types = types ?? [], + this.named = named ?? [] { setParents(this.positional, this); setParents(this.named, this); } - Arguments.empty() + new empty() : types = [], positional = [], named = []; - factory Arguments.forwarded(FunctionNode function) { + factory forwarded(FunctionNode function) { return new Arguments( function.positionalParameters .map((p) => new VariableGet(p)) @@ -1635,7 +1613,7 @@ class NamedExpression extends TreeNode { String name; Expression value; - NamedExpression(this.name, this.value) { + new(this.name, this.value) { value.parent = this; } @@ -1713,7 +1691,7 @@ class DynamicInvocation extends InstanceInvocationExpression { int flags = 0; - DynamicInvocation(this.kind, this.receiver, this.name, this.arguments) { + new(this.kind, this.receiver, this.name, this.arguments) { receiver.parent = this; arguments.parent = this; } @@ -1884,7 +1862,7 @@ class InstanceInvocation extends InstanceInvocationExpression { Reference interfaceTargetReference; - InstanceInvocation( + new( InstanceAccessKind kind, Expression receiver, Name name, @@ -1902,7 +1880,7 @@ class InstanceInvocation extends InstanceInvocationExpression { functionType: functionType, ); - InstanceInvocation.byReference( + new byReference( this.kind, this.receiver, this.name, @@ -2055,7 +2033,7 @@ class InstanceGetterInvocation extends InstanceInvocationExpression { Reference interfaceTargetReference; - InstanceGetterInvocation( + new( InstanceAccessKind kind, Expression receiver, Name name, @@ -2073,7 +2051,7 @@ class InstanceGetterInvocation extends InstanceInvocationExpression { functionType: functionType, ); - InstanceGetterInvocation.byReference( + new byReference( this.kind, this.receiver, this.name, @@ -2260,12 +2238,7 @@ class FunctionInvocation extends InstanceInvocationExpression { /// FunctionType? functionType; - FunctionInvocation( - this.kind, - this.receiver, - this.arguments, { - required this.functionType, - }) { + new(this.kind, this.receiver, this.arguments, {required this.functionType}) { receiver.parent = this; arguments.parent = this; } @@ -2354,11 +2327,7 @@ class LocalFunctionInvocation extends InvocationExpression { /// FunctionType functionType; - LocalFunctionInvocation( - this.variable, - this.arguments, { - required this.functionType, - }) { + new(this.variable, this.arguments, {required this.functionType}) { arguments.parent = this; } @@ -2420,7 +2389,7 @@ class EqualsNull extends Expression { /// The expression tested for nullness. Expression expression; - EqualsNull(this.expression) { + new(this.expression) { expression.parent = this; } @@ -2489,7 +2458,7 @@ class EqualsCall extends Expression { Reference interfaceTargetReference; - EqualsCall( + new( Expression left, Expression right, { required FunctionType functionType, @@ -2503,7 +2472,7 @@ class EqualsCall extends Expression { ), ); - EqualsCall.byReference( + new byReference( this.left, this.right, { required this.functionType, @@ -2608,7 +2577,7 @@ class AbstractSuperMethodInvocation extends InvocationExpression { Reference interfaceTargetReference; - AbstractSuperMethodInvocation( + new( Expression receiver, Name name, Arguments arguments, @@ -2621,7 +2590,7 @@ class AbstractSuperMethodInvocation extends InvocationExpression { getNonNullableMemberReferenceGetter(interfaceTarget), ); - AbstractSuperMethodInvocation.byReference( + new byReference( this.receiver, this.name, this.arguments, @@ -2712,7 +2681,7 @@ class SuperMethodInvocation extends InvocationExpression { Reference interfaceTargetReference; - SuperMethodInvocation( + new( Expression receiver, Name name, Arguments arguments, @@ -2725,7 +2694,7 @@ class SuperMethodInvocation extends InvocationExpression { getNonNullableMemberReferenceGetter(interfaceTarget), ); - SuperMethodInvocation.byReference( + new byReference( this.receiver, this.name, this.arguments, @@ -2817,18 +2786,15 @@ class StaticInvocation extends InvocationExpression { @override Name get name => target.name; - StaticInvocation( - Procedure target, - Arguments arguments, { - bool isConst = false, - }) : this.byReference( - // An invocation doesn't refer to the setter. - getNonNullableMemberReferenceGetter(target), - arguments, - isConst: isConst, - ); + new(Procedure target, Arguments arguments, {bool isConst = false}) + : this.byReference( + // An invocation doesn't refer to the setter. + getNonNullableMemberReferenceGetter(target), + arguments, + isConst: isConst, + ); - StaticInvocation.byReference( + new byReference( this.targetReference, this.arguments, { this.isConst = false, @@ -2906,18 +2872,15 @@ class ConstructorInvocation extends InvocationExpression { @override Name get name => target.name; - ConstructorInvocation( - Constructor target, - Arguments arguments, { - bool isConst = false, - }) : this.byReference( - // A constructor doesn't refer to the setter. - getNonNullableMemberReferenceGetter(target), - arguments, - isConst: isConst, - ); + new(Constructor target, Arguments arguments, {bool isConst = false}) + : this.byReference( + // A constructor doesn't refer to the setter. + getNonNullableMemberReferenceGetter(target), + arguments, + isConst: isConst, + ); - ConstructorInvocation.byReference( + new byReference( this.targetReference, this.arguments, { this.isConst = false, @@ -3025,10 +2988,7 @@ class RedirectingFactoryInvocation extends Expression { /// The invocation of the effective target. InvocationExpression expression; - factory RedirectingFactoryInvocation( - Procedure redirectingFactoryTarget, - InvocationExpression expression, - ) { + factory(Procedure redirectingFactoryTarget, InvocationExpression expression) { assert(redirectingFactoryTarget.isRedirectingFactory); return new RedirectingFactoryInvocation.byReference( redirectingFactoryTarget.reference, @@ -3036,10 +2996,7 @@ class RedirectingFactoryInvocation extends Expression { ); } - RedirectingFactoryInvocation.byReference( - this.redirectingFactoryTargetReference, - this.expression, - ) { + new byReference(this.redirectingFactoryTargetReference, this.expression) { expression.parent = this; } @@ -3101,7 +3058,7 @@ class Instantiation extends Expression { Expression expression; final List typeArguments; - Instantiation(this.expression, this.typeArguments) { + new(this.expression, this.typeArguments) { expression.parent = this; } @@ -3166,7 +3123,7 @@ class Instantiation extends Expression { class Not extends Expression { Expression operand; - Not(this.operand) { + new(this.operand) { operand.parent = this; } @@ -3233,7 +3190,7 @@ class LogicalExpression extends Expression { LogicalExpressionOperator operatorEnum; // AND (&&) or OR (||). Expression right; - LogicalExpression(this.left, this.operatorEnum, this.right) { + new(this.left, this.operatorEnum, this.right) { left.parent = this; right.parent = this; } @@ -3298,12 +3255,7 @@ class ConditionalExpression extends Expression { /// The static type of the expression. DartType staticType; - ConditionalExpression( - this.condition, - this.then, - this.otherwise, - this.staticType, - ) { + new(this.condition, this.then, this.otherwise, this.staticType) { condition.parent = this; then.parent = this; otherwise.parent = this; @@ -3385,7 +3337,7 @@ class ConditionalExpression extends Expression { class StringConcatenation extends Expression { final List expressions; - StringConcatenation(this.expressions) { + new(this.expressions) { setParents(expressions, this); } @@ -3451,7 +3403,7 @@ class ListConcatenation extends Expression { DartType typeArgument; final List lists; - ListConcatenation(this.lists, {this.typeArgument = const DynamicType()}) { + new(this.lists, {this.typeArgument = const DynamicType()}) { setParents(lists, this); } @@ -3521,7 +3473,7 @@ class SetConcatenation extends Expression { DartType typeArgument; final List sets; - SetConcatenation(this.sets, {this.typeArgument = const DynamicType()}) { + new(this.sets, {this.typeArgument = const DynamicType()}) { setParents(sets, this); } @@ -3592,7 +3544,7 @@ class MapConcatenation extends Expression { DartType valueType; final List maps; - MapConcatenation( + new( this.maps, { this.keyType = const DynamicType(), this.valueType = const DynamicType(), @@ -3672,7 +3624,7 @@ class InstanceCreation extends Expression { final List asserts; final List unusedArguments; - InstanceCreation( + new( this.classReference, this.typeArguments, this.fieldValues, @@ -3805,7 +3757,7 @@ class FileUriExpression extends Expression implements FileUriNode { Expression expression; - FileUriExpression(this.expression, this.fileUri) { + new(this.expression, this.fileUri) { expression.parent = this; } @@ -3870,7 +3822,7 @@ class IsExpression extends Expression { Expression operand; DartType type; - IsExpression(this.operand, this.type) { + new(this.operand, this.type) { operand.parent = this; } @@ -3931,7 +3883,7 @@ class AsExpression extends Expression { Expression operand; DartType type; - AsExpression(this.operand, this.type) { + new(this.operand, this.type) { operand.parent = this; } @@ -4072,7 +4024,7 @@ class AsExpression extends Expression { class NullCheck extends Expression { Expression operand; - NullCheck(this.operand) { + new(this.operand) { operand.parent = this; } @@ -4141,7 +4093,7 @@ class StringLiteral extends BasicLiteral { @override String value; - StringLiteral(this.value); + new(this.value); @override DartType getStaticType(StaticTypeContext context) => @@ -4179,7 +4131,7 @@ class IntLiteral extends BasicLiteral { @override int value; - IntLiteral(this.value); + new(this.value); @override DartType getStaticType(StaticTypeContext context) => @@ -4211,7 +4163,7 @@ class DoubleLiteral extends BasicLiteral { @override double value; - DoubleLiteral(this.value); + new(this.value); @override DartType getStaticType(StaticTypeContext context) => @@ -4243,7 +4195,7 @@ class BoolLiteral extends BasicLiteral { @override bool value; - BoolLiteral(this.value); + new(this.value); @override DartType getStaticType(StaticTypeContext context) => @@ -4303,7 +4255,7 @@ class NullLiteral extends BasicLiteral { class SymbolLiteral extends Expression { String value; // Everything strictly after the '#'. - SymbolLiteral(this.value); + new(this.value); @override DartType getStaticType(StaticTypeContext context) => @@ -4344,7 +4296,7 @@ class SymbolLiteral extends Expression { class TypeLiteral extends Expression { DartType type; - TypeLiteral(this.type); + new(this.type); @override DartType getStaticType(StaticTypeContext context) => @@ -4463,7 +4415,7 @@ class Throw extends Expression { Expression expression; int flags = 0; - Throw(this.expression) { + new(this.expression) { expression.parent = this; } @@ -4531,7 +4483,7 @@ class ListLiteral extends Expression { DartType typeArgument; // Not null, defaults to DynamicType. final List expressions; - ListLiteral( + new( this.expressions, { this.typeArgument = const DynamicType(), this.isConst = false, @@ -4596,7 +4548,7 @@ class SetLiteral extends Expression { DartType typeArgument; // Not null, defaults to DynamicType. final List expressions; - SetLiteral( + new( this.expressions, { this.typeArgument = const DynamicType(), this.isConst = false, @@ -4662,7 +4614,7 @@ class MapLiteral extends Expression { DartType valueType; // Not null, defaults to DynamicType. final List entries; - MapLiteral( + new( this.entries, { this.keyType = const DynamicType(), this.valueType = const DynamicType(), @@ -4741,7 +4693,7 @@ class MapLiteralEntry extends TreeNode { Expression key; Expression value; - MapLiteralEntry(this.key, this.value) { + new(this.key, this.value) { key.parent = this; value.parent = this; } @@ -4801,32 +4753,28 @@ class RecordLiteral extends Expression { final List named; RecordType recordType; - RecordLiteral( - this.positional, - this.named, - this.recordType, { - this.isConst = false, - }) : assert( - positional.length == recordType.positional.length && - named.length == recordType.named.length && - recordType.named - .map((f) => f.name) - .toSet() - .containsAll(named.map((f) => f.name)), - ), - assert( - () { - // Assert that the named fields are sorted. - for (int i = 1; i < named.length; i++) { - if (named[i].name.compareTo(named[i - 1].name) < 0) { - return false; - } - } - return true; - }(), - "Named fields of a RecordLiterals aren't sorted lexicographically: " - "${named.map((f) => f.name).join(", ")}", - ) { + new(this.positional, this.named, this.recordType, {this.isConst = false}) + : assert( + positional.length == recordType.positional.length && + named.length == recordType.named.length && + recordType.named + .map((f) => f.name) + .toSet() + .containsAll(named.map((f) => f.name)), + ), + assert( + () { + // Assert that the named fields are sorted. + for (int i = 1; i < named.length; i++) { + if (named[i].name.compareTo(named[i - 1].name) < 0) { + return false; + } + } + return true; + }(), + "Named fields of a RecordLiterals aren't sorted lexicographically: " + "${named.map((f) => f.name).join(", ")}", + ) { setParents(positional, this); setParents(named, this); } @@ -4933,7 +4881,7 @@ class AwaitExpression extends Expression { /// of which the check is needed. DartType? runtimeCheckType; - AwaitExpression(this.operand) { + new(this.operand) { operand.parent = this; } @@ -5007,9 +4955,8 @@ extension type const LocalFunctionId(int _value) { class LocalFunctionIdGenerator { LocalFunctionId _counter; - LocalFunctionIdGenerator() : _counter = LocalFunctionId.first; - LocalFunctionIdGenerator.after(LocalFunctionId lastUsedId) - : _counter = lastUsedId + 1; + new() : _counter = LocalFunctionId.first; + new after(LocalFunctionId lastUsedId) : _counter = lastUsedId + 1; /// Generate a new id for a local function within a [Member]. LocalFunctionId allocateId() => _counter++; @@ -5030,7 +4977,7 @@ class FunctionExpression extends Expression implements LocalFunction { @override LocalFunctionId id = LocalFunctionId.invalid; - FunctionExpression(this.function) { + new(this.function) { function.parent = this; } @@ -5081,7 +5028,7 @@ class ConstantExpression extends Expression { Constant constant; DartType type; - ConstantExpression(this.constant, [this.type = const DynamicType()]); + new(this.constant, [this.type = const DynamicType()]); @override DartType getStaticType(StaticTypeContext context) => @@ -5131,7 +5078,7 @@ class FileUriConstantExpression extends ConstantExpression @override Uri fileUri; - FileUriConstantExpression( + new( Constant constant, { DartType type = const DynamicType(), required this.fileUri, @@ -5153,7 +5100,7 @@ class Let extends Expression { Variable variable; // Must have an initializer. Expression body; - Let(this.variable, this.body) { + new(this.variable, this.body) { variable.parent = this; body.parent = this; } @@ -5215,7 +5162,7 @@ class BlockExpression extends Expression implements ScopeProvider { @override Scope? scope; - BlockExpression(this.body, this.value) { + new(this.body, this.value) { body.parent = this; value.parent = this; } @@ -5287,7 +5234,7 @@ class LoadLibrary extends Expression { /// Reference to a deferred import in the enclosing library. LibraryDependency import; - LoadLibrary(this.import); + new(this.import); @override DartType getStaticType(StaticTypeContext context) => @@ -5334,7 +5281,7 @@ class CheckLibraryIsLoaded extends Expression { /// Reference to a deferred import in the enclosing library. LibraryDependency import; - CheckLibraryIsLoaded(this.import); + new(this.import); @override DartType getStaticType(StaticTypeContext context) => @@ -5378,14 +5325,14 @@ class ConstructorTearOff extends Expression { /// The reference to the constructor being torn off. Reference targetReference; - ConstructorTearOff(Member target) + new(Member target) : assert( target is Constructor || (target is Procedure && target.isFactory), "Unexpected constructor tear off target: $target", ), this.targetReference = getNonNullableMemberReferenceGetter(target); - ConstructorTearOff.byReference(this.targetReference); + new byReference(this.targetReference); Member get target => targetReference.asMember; @@ -5438,11 +5385,11 @@ class RedirectingFactoryTearOff extends Expression { /// The reference to the redirecting factory constructor being torn off. Reference targetReference; - RedirectingFactoryTearOff(Procedure target) + new(Procedure target) : assert(target.isRedirectingFactory), this.targetReference = getNonNullableMemberReferenceGetter(target); - RedirectingFactoryTearOff.byReference(this.targetReference); + new byReference(this.targetReference); Procedure get target => targetReference.asProcedure; @@ -5491,11 +5438,7 @@ class TypedefTearOff extends Expression { Expression expression; final List typeArguments; - TypedefTearOff( - this.structuralParameters, - this.expression, - this.typeArguments, - ) { + new(this.structuralParameters, this.expression, this.typeArguments) { expression.parent = this; } diff --git a/pkg/kernel/lib/src/ast/functions.dart b/pkg/kernel/lib/src/ast/functions.dart index 143ccb6adaf..f617164e0f2 100644 --- a/pkg/kernel/lib/src/ast/functions.dart +++ b/pkg/kernel/lib/src/ast/functions.dart @@ -101,7 +101,7 @@ class FunctionNode extends TreeNode implements ScopeProvider, ContextConsumer { _body = body; } - FunctionNode( + new( this._body, { List? typeParameters, List? positionalParameters, diff --git a/pkg/kernel/lib/src/ast/helpers.dart b/pkg/kernel/lib/src/ast/helpers.dart index 87073d838c0..3b9afaa32d0 100644 --- a/pkg/kernel/lib/src/ast/helpers.dart +++ b/pkg/kernel/lib/src/ast/helpers.dart @@ -55,7 +55,7 @@ class DirtifyingList extends ListBase { final Class dirtifyClass; final List wrapped; - DirtifyingList(this.dirtifyClass, this.wrapped); + new(this.dirtifyClass, this.wrapped); @override int get length { @@ -102,7 +102,7 @@ class _ChildReplacer extends Transformer { final TreeNode child; final TreeNode replacement; - _ChildReplacer(this.child, this.replacement); + new(this.child, this.replacement); @override TreeNode defaultTreeNode(TreeNode node) { diff --git a/pkg/kernel/lib/src/ast/initializers.dart b/pkg/kernel/lib/src/ast/initializers.dart index d77d576d38b..2865cf64652 100644 --- a/pkg/kernel/lib/src/ast/initializers.dart +++ b/pkg/kernel/lib/src/ast/initializers.dart @@ -53,7 +53,7 @@ class InvalidInitializer extends Initializer { final String message; int flags = 0; - InvalidInitializer(this.message); + new(this.message); @override bool get isRedirectingInitializer => flags & FlagRedirectingInitializer != 0; @@ -118,10 +118,10 @@ class FieldInitializer extends Initializer { @override bool isSynthetic = false; - FieldInitializer(Field field, Expression value) + new(Field field, Expression value) : this.byReference(field.fieldReference, value); - FieldInitializer.byReference(this.fieldReference, this.value) { + new byReference(this.fieldReference, this.value) { value.parent = this; } @@ -184,14 +184,14 @@ class SuperInitializer extends Initializer { @override bool isSynthetic = false; - SuperInitializer(Constructor target, Arguments arguments) + new(Constructor target, Arguments arguments) : this.byReference( // Getter vs setter doesn't matter for constructors. getNonNullableMemberReferenceGetter(target), arguments, ); - SuperInitializer.byReference(this.targetReference, this.arguments) { + new byReference(this.targetReference, this.arguments) { arguments.parent = this; } @@ -256,14 +256,14 @@ class RedirectingInitializer extends Initializer { Reference targetReference; Arguments arguments; - RedirectingInitializer(Constructor target, Arguments arguments) + new(Constructor target, Arguments arguments) : this.byReference( // Getter vs setter doesn't matter for constructors. getNonNullableMemberReferenceGetter(target), arguments, ); - RedirectingInitializer.byReference(this.targetReference, this.arguments) { + new byReference(this.targetReference, this.arguments) { arguments.parent = this; } @@ -325,7 +325,7 @@ class RedirectingInitializer extends Initializer { class LocalInitializer extends Initializer { Variable variable; - LocalInitializer(this.variable) { + new(this.variable) { variable.parent = this; } @@ -367,7 +367,7 @@ class LocalInitializer extends Initializer { class AssertInitializer extends Initializer { AssertStatement statement; - AssertInitializer(this.statement) { + new(this.statement) { statement.parent = this; } diff --git a/pkg/kernel/lib/src/ast/libraries.dart b/pkg/kernel/lib/src/ast/libraries.dart index a01e1851d42..51c973c223f 100644 --- a/pkg/kernel/lib/src/ast/libraries.dart +++ b/pkg/kernel/lib/src/ast/libraries.dart @@ -100,7 +100,7 @@ class Library extends NamedNode List _procedures; List _fields; - Library( + new( this.importUri, { this.name, List? annotations, @@ -419,7 +419,7 @@ class LibraryDependency extends TreeNode implements Annotatable { final List combinators; - LibraryDependency.deferredImport( + new deferredImport( Library importedLibrary, String name, { List? combinators, @@ -432,7 +432,7 @@ class LibraryDependency extends TreeNode implements Annotatable { combinators ?? [], ); - LibraryDependency.import( + new import( Library importedLibrary, { String? name, List? combinators, @@ -445,7 +445,7 @@ class LibraryDependency extends TreeNode implements Annotatable { combinators ?? [], ); - LibraryDependency.export( + new export( Library importedLibrary, { List? combinators, List? annotations, @@ -457,7 +457,7 @@ class LibraryDependency extends TreeNode implements Annotatable { combinators ?? [], ); - LibraryDependency.byReference( + new byReference( this.flags, this.annotations, this.importedLibraryReference, @@ -539,7 +539,7 @@ class LibraryPart extends TreeNode implements Annotatable { final String partUri; - LibraryPart(this.annotations, this.partUri) { + new(this.annotations, this.partUri) { setParents(annotations, this); } @@ -586,9 +586,9 @@ class Combinator extends TreeNode { final List names; - Combinator(this.isShow, this.names); - Combinator.show(this.names) : isShow = true; - Combinator.hide(this.names) : isShow = false; + new(this.isShow, this.names); + new show(this.names) : isShow = true; + new hide(this.names) : isShow = false; bool get isHide => !isShow; diff --git a/pkg/kernel/lib/src/ast/members.dart b/pkg/kernel/lib/src/ast/members.dart index 76d401ef48a..cd4367711e4 100644 --- a/pkg/kernel/lib/src/ast/members.dart +++ b/pkg/kernel/lib/src/ast/members.dart @@ -49,7 +49,7 @@ sealed class Member extends NamedNode implements Annotatable, FileUriNode { // TODO(asgerf): It might be worthwhile to put this on classes as well. int transformerFlags = 0; - Member(this.name, this.fileUri, Reference? reference) : super(reference); + new(this.name, this.fileUri, Reference? reference) : super(reference); /// The enclosing [TypeDeclaration] if this member a class member or an /// abstract extension type member. @@ -294,7 +294,7 @@ class Field extends Member implements ScopeProvider { @override Scope? scope; - Field.mutable( + new mutable( Name name, { this.type = const DynamicType(), this.initializer, @@ -320,7 +320,7 @@ class Field extends Member implements ScopeProvider { this.transformerFlags = transformerFlags; } - Field.immutable( + new immutable( Name name, { this.type = const DynamicType(), this.initializer, @@ -582,7 +582,7 @@ class Constructor extends Member { List initializers; - Constructor( + new( this.function, { required Name name, bool isConst = false, @@ -974,7 +974,7 @@ class Procedure extends Member implements GenericFunction { /// being null. FunctionType? signatureType; - Procedure( + new( Name name, ProcedureKind kind, FunctionNode function, { @@ -1011,7 +1011,7 @@ class Procedure extends Member implements GenericFunction { ), ); - Procedure._byReferenceRenamed( + new _byReferenceRenamed( Name name, this.kind, this.function, { @@ -1371,15 +1371,15 @@ class RedirectingFactoryTarget { /// otherwise. final String? errorMessage; - RedirectingFactoryTarget(Member target, List typeArguments) + new(Member target, List typeArguments) : this.byReference(target.reference, typeArguments); - RedirectingFactoryTarget.byReference( + new byReference( Reference this.targetReference, List this.typeArguments, ) : errorMessage = null; - RedirectingFactoryTarget.error(String this.errorMessage) + new error(String this.errorMessage) : targetReference = null, typeArguments = null; diff --git a/pkg/kernel/lib/src/ast/misc.dart b/pkg/kernel/lib/src/ast/misc.dart index bc9d43cdb6b..2ee1669724e 100644 --- a/pkg/kernel/lib/src/ast/misc.dart +++ b/pkg/kernel/lib/src/ast/misc.dart @@ -6,7 +6,7 @@ part of '../../ast.dart'; /// Any type of node in the IR. abstract class Node { - const Node(); + const new(); R accept(Visitor v); R accept1(Visitor1 v, A arg); @@ -133,8 +133,7 @@ abstract class TreeNode extends Node { abstract class NamedNode extends TreeNode { final Reference reference; - NamedNode(Reference? reference) - : this.reference = reference ?? new Reference() { + new(Reference? reference) : this.reference = reference ?? new Reference() { this.reference.node = this; } @@ -180,7 +179,7 @@ class Version extends Object { final int major; final int minor; - const Version(this.major, this.minor); + const new(this.major, this.minor); bool operator <(Version other) { if (major < other.major) return true; diff --git a/pkg/kernel/lib/src/ast/names.dart b/pkg/kernel/lib/src/ast/names.dart index 9f72f5d31bb..ec1e0ec5804 100644 --- a/pkg/kernel/lib/src/ast/names.dart +++ b/pkg/kernel/lib/src/ast/names.dart @@ -27,12 +27,12 @@ abstract class Name extends Node { Library? get library; bool get isPrivate; - Name._internal(this.hashCode, this.text); + new _internal(this.hashCode, this.text); - factory Name(String text, [Library? library]) => + factory(String text, [Library? library]) => new Name.byReference(text, library?.reference); - factory Name.byReference(String text, Reference? libraryName) { + factory byReference(String text, Reference? libraryName) { /// Use separate subclasses for the public and private case to save memory /// for public names. if (text.startsWith('_')) { @@ -85,7 +85,7 @@ class _PrivateName extends Name { @override bool get isPrivate => true; - _PrivateName(String text, Reference libraryReference) + new(String text, Reference libraryReference) : this.libraryReference = libraryReference, super._internal(_computeHashCode(text, libraryReference), text); @@ -117,7 +117,7 @@ class _PublicName extends Name { @override bool get isPrivate => false; - _PublicName(String text) : super._internal(text.hashCode, text); + new(String text) : super._internal(text.hashCode, text); @override String toString() => toStringInternal(); diff --git a/pkg/kernel/lib/src/ast/patterns.dart b/pkg/kernel/lib/src/ast/patterns.dart index 647c08fb5a0..9a0800c5a9c 100644 --- a/pkg/kernel/lib/src/ast/patterns.dart +++ b/pkg/kernel/lib/src/ast/patterns.dart @@ -50,7 +50,7 @@ class ConstantPattern extends Pattern { /// This is set during constant evaluation. Constant? value; - ConstantPattern(this.expression) { + new(this.expression) { expression.parent = this; } @@ -110,7 +110,7 @@ class AndPattern extends Pattern { ...right.declaredVariables, ]; - AndPattern(this.left, this.right) { + new(this.left, this.right) { left.parent = this; right.parent = this; } @@ -163,11 +163,8 @@ class OrPattern extends Pattern { @override List get declaredVariables => orPatternJointVariables; - OrPattern( - this.left, - this.right, { - required List orPatternJointVariables, - }) : orPatternJointVariables = orPatternJointVariables { + new(this.left, this.right, {required List orPatternJointVariables}) + : orPatternJointVariables = orPatternJointVariables { left.parent = this; right.parent = this; } @@ -215,7 +212,7 @@ class CastPattern extends Pattern { Pattern pattern; DartType type; - CastPattern(this.pattern, this.type) { + new(this.pattern, this.type) { pattern.parent = this; } @@ -267,7 +264,7 @@ class CastPattern extends Pattern { class NullAssertPattern extends Pattern { Pattern pattern; - NullAssertPattern(this.pattern) { + new(this.pattern) { pattern.parent = this; } @@ -316,7 +313,7 @@ class NullAssertPattern extends Pattern { class NullCheckPattern extends Pattern { Pattern pattern; - NullCheckPattern(this.pattern) { + new(this.pattern) { pattern.parent = this; } @@ -482,7 +479,7 @@ class ListPattern extends Pattern { for (Pattern pattern in patterns) ...pattern.declaredVariables, ]; - ListPattern(this.typeArgument, this.patterns) { + new(this.typeArgument, this.patterns) { setParents(patterns, this); } @@ -628,7 +625,7 @@ class ObjectPattern extends Pattern { // TODO(johnniwinther): Remove this field. It is no longer used. DartType? lookupType; - ObjectPattern(this.requiredType, this.fields) { + new(this.requiredType, this.fields) { setParents(fields, this); } @@ -744,7 +741,7 @@ class RelationalPattern extends Pattern { /// This is set during constant evaluation. Constant? expressionValue; - RelationalPattern(this.kind, this.expression) { + new(this.kind, this.expression) { expression.parent = this; } @@ -820,7 +817,7 @@ class RelationalPattern extends Pattern { class WildcardPattern extends Pattern { DartType? type; - WildcardPattern(this.type); + new(this.type); @override List get declaredVariables => const []; @@ -916,7 +913,7 @@ class AssignedVariablePattern extends Pattern { /// not. bool hasObservableEffect = true; - AssignedVariablePattern(this.variable); + new(this.variable); @override R accept(PatternVisitor visitor) => @@ -1021,7 +1018,7 @@ class MapPattern extends Pattern { if (entry is! MapPatternRestEntry) ...entry.value.declaredVariables, ]; - MapPattern(this.keyType, this.valueType, this.entries) + new(this.keyType, this.valueType, this.entries) : assert((keyType == null) == (valueType == null)) { setParents(entries, this); } @@ -1184,7 +1181,7 @@ class NamedPattern extends Pattern { @override List get declaredVariables => pattern.declaredVariables; - NamedPattern(this.name, this.pattern) { + new(this.name, this.pattern) { pattern.parent = this; } @@ -1272,7 +1269,7 @@ class RecordPattern extends Pattern { for (Pattern pattern in patterns) ...pattern.declaredVariables, ]; - RecordPattern(this.patterns) { + new(this.patterns) { setParents(patterns, this); } @@ -1329,7 +1326,7 @@ class VariablePattern extends Pattern { @override List get declaredVariables => [variable]; - VariablePattern(this.type, this.variable) { + new(this.type, this.variable) { variable.parent = this; } @@ -1390,7 +1387,7 @@ class VariablePattern extends Pattern { class RestPattern extends Pattern { Pattern? subPattern; - RestPattern(this.subPattern) { + new(this.subPattern) { subPattern?.parent = this; } @@ -1444,7 +1441,7 @@ class InvalidPattern extends Pattern { @override final List declaredVariables; - InvalidPattern(this.invalidExpression, {required this.declaredVariables}) { + new(this.invalidExpression, {required this.declaredVariables}) { invalidExpression.parent = this; setParents(declaredVariables, this); } @@ -1507,7 +1504,7 @@ class MapPatternEntry extends TreeNode { /// This is set during constant evaluation. Constant? keyValue; - MapPatternEntry(this.key, this.value) { + new(this.key, this.value) { key.parent = this; value.parent = this; } @@ -1561,7 +1558,7 @@ class MapPatternEntry extends TreeNode { } class MapPatternRestEntry extends TreeNode implements MapPatternEntry { - MapPatternRestEntry(); + new(); @override Expression get key => throw new UnsupportedError('MapPatternRestEntry.key'); @@ -1685,7 +1682,7 @@ class PatternGuard extends TreeNode { Pattern pattern; Expression? guard; - PatternGuard(this.pattern, [this.guard]) { + new(this.pattern, [this.guard]) { pattern.parent = this; guard?.parent = this; } @@ -1757,7 +1754,7 @@ class PatternSwitchCase extends TreeNode implements SwitchCase { // TODO(johnniwinther): Serialize this field. final List? jointVariableFirstUseOffsets; - PatternSwitchCase( + new( this.caseOffsets, this.patternGuards, this.body, { @@ -1862,7 +1859,7 @@ class PatternSwitchStatement extends Statement implements SwitchStatement { // TODO(johnniwinther): Serialize this. bool lastCaseTerminates = false; - PatternSwitchStatement(this.expression, this.cases) { + new(this.expression, this.cases) { expression.parent = this; setParents(cases, this); } @@ -1948,7 +1945,7 @@ class SwitchExpressionCase extends TreeNode { PatternGuard patternGuard; Expression expression; - SwitchExpressionCase(this.patternGuard, this.expression) { + new(this.patternGuard, this.expression) { patternGuard.parent = this; expression.parent = this; } @@ -2009,7 +2006,7 @@ class SwitchExpression extends Expression { /// This is set during inference. DartType? staticType; - SwitchExpression(this.expression, this.cases) { + new(this.expression, this.cases) { expression.parent = this; setParents(cases, this); } @@ -2080,11 +2077,7 @@ class PatternVariableDeclaration extends Statement { /// This is set during inference. DartType? matchedValueType; - PatternVariableDeclaration( - this.pattern, - this.initializer, { - required this.isFinal, - }) { + new(this.pattern, this.initializer, {required this.isFinal}) { pattern.parent = this; initializer.parent = this; } @@ -2145,7 +2138,7 @@ class PatternAssignment extends Expression { /// This is set during inference. DartType? matchedValueType; - PatternAssignment(this.pattern, this.expression) { + new(this.pattern, this.expression) { pattern.parent = this; expression.parent = this; } @@ -2214,12 +2207,7 @@ class IfCaseStatement extends Statement { /// This is set during inference. DartType? matchedValueType; - IfCaseStatement( - this.expression, - this.patternGuard, - this.then, [ - this.otherwise, - ]) { + new(this.expression, this.patternGuard, this.then, [this.otherwise]) { expression.parent = this; patternGuard.parent = this; then.parent = this; diff --git a/pkg/kernel/lib/src/ast/statements.dart b/pkg/kernel/lib/src/ast/statements.dart index b31a005212e..b53f3ef8009 100644 --- a/pkg/kernel/lib/src/ast/statements.dart +++ b/pkg/kernel/lib/src/ast/statements.dart @@ -42,7 +42,7 @@ class ExpressionStatement extends Statement { @override int get fileOffset => expression.fileOffset; - ExpressionStatement(this.expression) { + new(this.expression) { expression.parent = this; } @@ -96,7 +96,7 @@ class Block extends Statement implements ScopeProvider { @override Scope? scope; - Block(this.statements) { + new(this.statements) { // Ensure statements is mutable. assert(checkListIsMutable(statements, dummyStatement)); setParents(statements, this); @@ -147,7 +147,7 @@ class Block extends Statement implements ScopeProvider { class AssertBlock extends Statement { final List statements; - AssertBlock(this.statements) { + new(this.statements) { // Ensure statements is mutable. assert(checkListIsMutable(statements, dummyStatement)); setParents(statements, this); @@ -236,7 +236,7 @@ class AssertStatement extends Statement { conditionEndOffset, ]; - AssertStatement( + new( this.condition, { this.message, required this.conditionStartOffset, @@ -304,7 +304,7 @@ class AssertStatement extends Statement { class LabeledStatement extends Statement { late Statement body; - LabeledStatement(Statement? body) { + new(Statement? body) { if (body != null) { this.body = body..parent = this; } @@ -389,7 +389,7 @@ class LabeledStatement extends Statement { class BreakStatement extends Statement { LabeledStatement target; - BreakStatement(this.target); + new(this.target); @override R accept(StatementVisitor v) => v.visitBreakStatement(this); @@ -434,7 +434,7 @@ class WhileStatement extends Statement implements LoopStatement, ScopeProvider { @override Scope? scope; - WhileStatement(this.condition, this.body) { + new(this.condition, this.body) { condition.parent = this; body.parent = this; } @@ -488,7 +488,7 @@ class DoStatement extends Statement implements LoopStatement { Expression condition; - DoStatement(this.body, this.condition) { + new(this.body, this.condition) { body.parent = this; condition.parent = this; } @@ -553,7 +553,7 @@ class ForStatement extends Statement implements LoopStatement, ScopeProvider { @override Scope? scope; - ForStatement(this.variables, this.condition, this.updates, this.body) { + new(this.variables, this.condition, this.updates, this.body) { setParents(variables, this); condition?.parent = this; setParents(updates, this); @@ -650,12 +650,7 @@ class ForInStatement extends Statement implements LoopStatement, ScopeProvider { @override Scope? scope; - ForInStatement( - this.variable, - this.iterable, - this.body, { - this.isAsync = false, - }) { + new(this.variable, this.iterable, this.body, {this.isAsync = false}) { variable.parent = this; iterable.parent = this; body.parent = this; @@ -823,11 +818,7 @@ class SwitchStatement extends Statement { /// This is set during inference. DartType? expressionTypeInternal; - SwitchStatement( - this.expression, - this.cases, { - this.isExplicitlyExhaustive = false, - }) { + new(this.expression, this.cases, {this.isExplicitlyExhaustive = false}) { expression.parent = this; setParents(cases, this); } @@ -924,7 +915,7 @@ class SwitchCase extends TreeNode { late Statement body; bool isDefault; - SwitchCase( + new( this.expressions, this.expressionOffsets, Statement? body, { @@ -936,7 +927,7 @@ class SwitchCase extends TreeNode { } } - SwitchCase.defaultCase(Statement? body) + new defaultCase(Statement? body) : isDefault = true, expressions = [], expressionOffsets = [] { @@ -1021,7 +1012,7 @@ class SwitchCase extends TreeNode { class ContinueSwitchStatement extends Statement { SwitchCase target; - ContinueSwitchStatement(this.target); + new(this.target); @override R accept(StatementVisitor v) => v.visitContinueSwitchStatement(this); @@ -1057,7 +1048,7 @@ class IfStatement extends Statement { Statement then; Statement? otherwise; - IfStatement(this.condition, this.then, this.otherwise) { + new(this.condition, this.then, this.otherwise) { condition.parent = this; then.parent = this; otherwise?.parent = this; @@ -1122,7 +1113,7 @@ class IfStatement extends Statement { class ReturnStatement extends Statement { Expression? expression; // May be null. - ReturnStatement([this.expression]) { + new([this.expression]) { expression?.parent = this; } @@ -1175,7 +1166,7 @@ class TryCatch extends Statement { List catches; bool isSynthetic; - TryCatch(this.body, this.catches, {this.isSynthetic = false}) { + new(this.body, this.catches, {this.isSynthetic = false}) { body.parent = this; setParents(catches, this); } @@ -1232,7 +1223,7 @@ class Catch extends TreeNode implements ScopeProvider { @override Scope? scope; - Catch( + new( this.exception, this.body, { this.guard = const DynamicType(), @@ -1349,7 +1340,7 @@ class TryFinally extends Statement { Statement body; Statement finalizer; - TryFinally(this.body, this.finalizer) { + new(this.body, this.finalizer) { body.parent = this; finalizer.parent = this; } @@ -1405,7 +1396,7 @@ class YieldStatement extends Statement { Expression expression; int flags = 0; - YieldStatement(this.expression, {bool isYieldStar = false}) { + new(this.expression, {bool isYieldStar = false}) { expression.parent = this; this.isYieldStar = isYieldStar; } @@ -1464,7 +1455,7 @@ class VariableStatement extends Statement { /// The declared variable. VariableDeclaration declaration; - VariableStatement(this.declaration) { + new(this.declaration) { declaration.parent = this; } @@ -1517,7 +1508,7 @@ class FunctionDeclaration extends Statement implements LocalFunction { @override LocalFunctionId id = LocalFunctionId.invalid; - FunctionDeclaration(this.variable, this.function) { + new(this.variable, this.function) { variable.parent = this; function.parent = this; } diff --git a/pkg/kernel/lib/src/ast/typedefs.dart b/pkg/kernel/lib/src/ast/typedefs.dart index 3a3915779c8..69df4458699 100644 --- a/pkg/kernel/lib/src/ast/typedefs.dart +++ b/pkg/kernel/lib/src/ast/typedefs.dart @@ -22,7 +22,7 @@ class Typedef extends NamedNode // TODO(johnniwinther): Make this non-nullable. DartType? type; - Typedef( + new( this.name, this.type, { Reference? reference, diff --git a/pkg/kernel/lib/src/ast/types.dart b/pkg/kernel/lib/src/ast/types.dart index 06b17128014..5759a41c6b7 100644 --- a/pkg/kernel/lib/src/ast/types.dart +++ b/pkg/kernel/lib/src/ast/types.dart @@ -60,11 +60,8 @@ abstract interface class TypeParameter implements TreeNode, Annotatable { static const int legacyCovariantSerializationMarker = 4; - factory TypeParameter([ - String? name, - DartType? bound, - DartType? defaultType, - ]) = NominalParameter; + factory([String? name, DartType? bound, DartType? defaultType]) = + NominalParameter; abstract int flags; @@ -161,7 +158,7 @@ class NominalParameter extends TreeNode implements TypeParameter { @override bool get isLegacyCovariant => _variance == null; - NominalParameter([this.name, DartType? bound, DartType? defaultType]) + new([this.name, DartType? bound, DartType? defaultType]) : bound = bound ?? TypeParameter.unsetBoundSentinel, defaultType = defaultType ?? TypeParameter.unsetDefaultTypeSentinel; @@ -366,7 +363,7 @@ class StructuralParameter extends Node implements SharedTypeParameter { static const int legacyCovariantSerializationMarker = 4; - StructuralParameter([this.name, DartType? bound, DartType? defaultType]) + new([this.name, DartType? bound, DartType? defaultType]) : bound = bound ?? unsetBoundSentinel, defaultType = defaultType ?? unsetDefaultTypeSentinel; @@ -442,10 +439,10 @@ class Supertype extends Node { Reference className; final List typeArguments; - Supertype(Class classNode, List typeArguments) + new(Class classNode, List typeArguments) : this.byReference(classNode.reference, typeArguments); - Supertype.byReference(this.className, this.typeArguments); + new byReference(this.className, this.typeArguments); Class get classNode => className.asClass; @@ -516,7 +513,7 @@ class Supertype extends Node { /// The `==` operator on [DartType]s compare based on type equality, not /// object identity. sealed class DartType extends Node implements SharedType { - const DartType(); + const new(); @override R accept(DartTypeVisitor v); @@ -665,7 +662,7 @@ sealed class TypeDeclarationType extends DartType { } abstract class AuxiliaryType extends DartType { - const AuxiliaryType(); + const new(); @override R accept(DartTypeVisitor v) => v.visitAuxiliaryType(this); @@ -682,7 +679,7 @@ abstract class AuxiliaryType extends DartType { /// an update whenever an experimental type (a subclass of [ExperimentalType]) /// is added or removed in the CFE. sealed class ExperimentalType extends DartType { - const ExperimentalType(); + const new(); @override R accept(DartTypeVisitor v) { @@ -703,7 +700,7 @@ class InvalidType extends DartType implements SharedInvalidType { @override final int hashCode = 12345; - const InvalidType(); + const new(); @override R accept(DartTypeVisitor v) => v.visitInvalidType(this); @@ -756,7 +753,7 @@ class DynamicType extends DartType implements SharedDynamicType { @override final int hashCode = 54321; - const DynamicType(); + const new(); @override R accept(DartTypeVisitor v) => v.visitDynamicType(this); @@ -801,7 +798,7 @@ class VoidType extends DartType implements SharedVoidType { @override final int hashCode = 123121; - const VoidType(); + const new(); @override R accept(DartTypeVisitor v) => v.visitVoidType(this); @@ -846,11 +843,11 @@ class NeverType extends DartType { @override final Nullability declaredNullability; - const NeverType.nullable() : this.internal(Nullability.nullable); + const new nullable() : this.internal(Nullability.nullable); - const NeverType.nonNullable() : this.internal(Nullability.nonNullable); + const new nonNullable() : this.internal(Nullability.nonNullable); - const NeverType.internal(this.declaredNullability) + const new internal(this.declaredNullability) : assert(declaredNullability != Nullability.undetermined); static NeverType fromNullability(Nullability nullability) { @@ -922,7 +919,7 @@ class NullType extends DartType implements SharedNullType { @override final int hashCode = 415324; - const NullType(); + const new(); @override R accept(DartTypeVisitor v) => v.visitNullType(this); @@ -975,7 +972,7 @@ class InterfaceType extends TypeDeclarationType { /// The [typeArguments] list must not be modified after this call. If the /// list is omitted, 'dynamic' type arguments are filled in. - InterfaceType( + new( Class classNode, Nullability declaredNullability, [ List? typeArguments, @@ -985,7 +982,7 @@ class InterfaceType extends TypeDeclarationType { typeArguments ?? _defaultTypeArguments(classNode), ); - InterfaceType.byReference( + new byReference( this.classReference, this.declaredNullability, this.typeArguments, @@ -1102,7 +1099,7 @@ class FunctionType extends DartType implements SharedFunctionType { @override late final int hashCode = _computeHashCode(); - FunctionType( + new( List positionalParameters, this.returnType, this.declaredNullability, { @@ -1338,17 +1335,14 @@ class TypedefType extends DartType { final Reference typedefReference; final List typeArguments; - TypedefType( - Typedef typedef, - Nullability nullability, [ - List? typeArguments, - ]) : this.byReference( - typedef.reference, - nullability, - typeArguments ?? const [], - ); + new(Typedef typedef, Nullability nullability, [List? typeArguments]) + : this.byReference( + typedef.reference, + nullability, + typeArguments ?? const [], + ); - TypedefType.byReference( + new byReference( this.typedefReference, this.declaredNullability, this.typeArguments, @@ -1459,7 +1453,7 @@ class FutureOrType extends DartType { @override final Nullability declaredNullability; - FutureOrType(this.typeArgument, this.declaredNullability); + new(this.typeArgument, this.declaredNullability); @override Nullability get nullability { @@ -1539,7 +1533,7 @@ class ExtensionType extends TypeDeclarationType { @override final List typeArguments; - ExtensionType( + new( ExtensionTypeDeclaration extensionTypeDeclaration, Nullability declaredNullability, [ List? typeArguments, @@ -1549,7 +1543,7 @@ class ExtensionType extends TypeDeclarationType { typeArguments ?? _defaultTypeArguments(extensionTypeDeclaration), ); - ExtensionType.byReference( + new byReference( this.extensionTypeDeclarationReference, this.declaredNullability, this.typeArguments, @@ -1739,7 +1733,7 @@ class NamedType extends Node @override final bool isRequired; - const NamedType(this.name, this.type, {this.isRequired = false}); + const new(this.name, this.type, {this.isRequired = false}); @override String get nameShared => name; @@ -1804,7 +1798,7 @@ class IntersectionType extends DartType { final TypeParameterType left; final DartType right; - IntersectionType(this.left, this.right) { + new(this.left, this.right) { // TODO(cstefantsova): Also assert that [rhs] is a subtype of [lhs.bound]. Nullability leftNullability = left.nullability; @@ -2114,14 +2108,14 @@ class TypeParameterType extends DartType implements TypeParameterTypeInterface { @override final TypeParameter parameter; - TypeParameterType(this.parameter, this.declaredNullability); + new(this.parameter, this.declaredNullability); /// Creates a type parameter type with default nullability. /// /// The nullability is computed as if the programmer omitted the modifier. /// Either `Nullability.nonNullable` or `Nullability.undetermined` will be /// used, depending on the nullability of the bound of [parameter]. - TypeParameterType.withDefaultNullability(this.parameter) + new withDefaultNullability(this.parameter) : declaredNullability = parameter.computeNullabilityFromBound(); @override @@ -2204,14 +2198,14 @@ class StructuralParameterType extends DartType { final StructuralParameter parameter; - StructuralParameterType(this.parameter, this.declaredNullability); + new(this.parameter, this.declaredNullability); /// Creates a structural parameter type with default nullability. /// /// The nullability is computed as if the programmer omitted the modifier. /// Either [Nullability.nonNullable] or [Nullability.undetermined] will be /// used, depending on the nullability of the bound of [parameter]. - StructuralParameterType.withDefaultNullability(this.parameter) + new withDefaultNullability(this.parameter) : declaredNullability = parameter.computeNullabilityFromBound(); @override @@ -2307,7 +2301,7 @@ class RecordType extends DartType implements SharedRecordType { @override final Nullability declaredNullability; - RecordType(this.positional, this.named, this.declaredNullability) + new(this.positional, this.named, this.declaredNullability) : /*TODO(johnniwinther): Enabled this assert: assert(named.length == named.map((p) => p.name).toSet().length, "Named field types must have unique names in a RecordType: " @@ -2455,7 +2449,7 @@ class TypeVariable extends VariableBase { @override late VariableContext context; - TypeVariable({this.cosmeticName, required this.parameter}); + new({this.cosmeticName, required this.parameter}); @override void addAnnotation(Expression annotation) { @@ -2518,10 +2512,7 @@ class FunctionTypeParameterType extends ExperimentalType @override Nullability declaredNullability; - FunctionTypeParameterType({ - required this.variable, - required this.declaredNullability, - }); + new({required this.variable, required this.declaredNullability}); @override TypeParameter get parameter => variable.parameter; @@ -2593,7 +2584,7 @@ class ClassTypeParameterType extends ExperimentalType @override Nullability declaredNullability; - ClassTypeParameterType({ + new({ required this.thisVariable, required this.parameter, required this.declaredNullability, diff --git a/pkg/kernel/lib/src/ast/variables.dart b/pkg/kernel/lib/src/ast/variables.dart index dcab88d8cb6..05ca3ca0040 100644 --- a/pkg/kernel/lib/src/ast/variables.dart +++ b/pkg/kernel/lib/src/ast/variables.dart @@ -121,7 +121,7 @@ sealed class Variable extends VariableBase @override abstract bool isErroneouslyInitialized; - factory Variable( + factory( String? name, { Expression? initializer, DartType type, @@ -140,7 +140,7 @@ sealed class Variable extends VariableBase bool isWildcard, }) = LegacyVariable; - factory Variable.forValue( + factory forValue( Expression? initializer, { bool isFinal, bool isConst, @@ -152,7 +152,7 @@ sealed class Variable extends VariableBase DartType type, }) = LegacyVariable.forValue; - Variable.empty(); + new empty(); @override bool get hasIsFinal; @@ -249,7 +249,7 @@ class LegacyVariable extends TreeNode implements Variable, Annotatable { @override Expression? initializer; // May be null. - LegacyVariable( + new( this._name, { this.initializer, this.type = const DynamicType(), @@ -291,7 +291,7 @@ class LegacyVariable extends TreeNode implements Variable, Annotatable { } /// Creates a synthetic variable with the given expression as initializer. - LegacyVariable.forValue( + new forValue( this.initializer, { bool isFinal = true, bool isConst = false, @@ -724,7 +724,7 @@ class LocalVariable extends Variable { // TODO(johnniwinther): Remove this. Expression? initializer; - LocalVariable({ + new({ this.cosmeticName, required DartType? type, bool isFinal = false, @@ -1036,7 +1036,7 @@ class LateVariable extends Variable { // TODO(johnniwinther): Rename to [initialValue]. Expression? initializer; - LateVariable({ + new({ this.cosmeticName, required DartType? type, bool isFinal = false, @@ -1351,7 +1351,7 @@ class CatchVariable extends Variable { @override late VariableContext context; - CatchVariable({ + new({ required String name, required DartType? type, bool isWildcard = false, @@ -1651,7 +1651,7 @@ class CatchVariable extends Variable { sealed class FunctionParameter extends Variable { Expression? defaultValue; - FunctionParameter({ + new({ required Expression? defaultValue, required bool isCovariantByDeclaration, required bool isRequired, @@ -1861,7 +1861,7 @@ class PositionalParameter extends FunctionParameter { @override late VariableContext context; - PositionalParameter({ + new({ this.cosmeticName, required this.type, super.defaultValue, @@ -2014,7 +2014,7 @@ class NamedParameter extends FunctionParameter { @override late VariableContext context; - NamedParameter({ + new({ required this.parameterName, required this.type, super.defaultValue, @@ -2170,7 +2170,7 @@ class ThisVariable extends Variable { @override late VariableContext context; - ThisVariable({required this.type}) : super.empty(); + new({required this.type}) : super.empty(); // TODO(cstefantsova): Consider a throwing implementation instead. @override @@ -2458,7 +2458,7 @@ class SyntheticVariable extends Variable { // TODO(johnniwinther): Remove this. Expression? initializer; - SyntheticVariable({ + new({ this.cosmeticName, required this.type, this.initializer, @@ -2740,7 +2740,7 @@ class VariableContext { final CaptureKind captureKind; final List variables; - VariableContext({required this.captureKind, required this.variables}); + new({required this.captureKind, required this.variables}); void addVariable(VariableBase variable) { variable.context = this; @@ -2774,7 +2774,7 @@ class VariableContext { class Scope { final List contexts; - Scope({required this.contexts}); + new({required this.contexts}); void addContext(VariableContext context) { contexts.add(context); @@ -2828,7 +2828,7 @@ class VariableDeclaration extends TreeNode implements ContextConsumer { @override List? capturedContexts; - VariableDeclaration(this.variable) { + new(this.variable) { variable.parent = this; variable.variableDeclaration = this; } diff --git a/pkg/kernel/lib/src/bounds_checks.dart b/pkg/kernel/lib/src/bounds_checks.dart index 308038b1b8b..f239fc49df8 100644 --- a/pkg/kernel/lib/src/bounds_checks.dart +++ b/pkg/kernel/lib/src/bounds_checks.dart @@ -18,7 +18,7 @@ class TypeVariableGraph extends Graph { // variable with the index `i` in their bounds. late List> edges; - TypeVariableGraph(this.typeParameters, this.bounds) { + new(this.typeParameters, this.bounds) { assert(typeParameters.length == bounds.length); vertices = new List.filled( @@ -59,7 +59,7 @@ class OccurrenceCollectorVisitor implements DartTypeVisitor { final Set typeParameters; Set occurred = new Set(); - OccurrenceCollectorVisitor(this.typeParameters); + new(this.typeParameters); void visit(DartType node) => node.accept(this); @@ -320,7 +320,7 @@ class TypeArgumentIssue { final bool isGenericTypeAsArgumentIssue; - TypeArgumentIssue( + new( this.index, this.argument, this.typeParameter, @@ -590,7 +590,7 @@ class _SuperBoundedTypeInverter extends ReplacementVisitor { final TypeEnvironment typeEnvironment; bool isOutermost = true; - _SuperBoundedTypeInverter(this.typeEnvironment); + new(this.typeEnvironment); bool flipTop(Variance variance) { return variance != Variance.contravariant; @@ -777,16 +777,14 @@ enum VarianceCalculationValue { final Variance? variance; - const VarianceCalculationValue(this.variance); + new(this.variance); - factory VarianceCalculationValue.fromVariance(Variance variance) => - switch (variance) { - Variance.unrelated => VarianceCalculationValue.calculatedUnrelated, - Variance.covariant => VarianceCalculationValue.calculatedCovariant, - Variance.contravariant => - VarianceCalculationValue.calculatedContravariant, - Variance.invariant => VarianceCalculationValue.calculatedInvariant, - }; + factory fromVariance(Variance variance) => switch (variance) { + Variance.unrelated => VarianceCalculationValue.calculatedUnrelated, + Variance.covariant => VarianceCalculationValue.calculatedCovariant, + Variance.contravariant => VarianceCalculationValue.calculatedContravariant, + Variance.invariant => VarianceCalculationValue.calculatedInvariant, + }; bool get isCalculated => variance != null; } @@ -799,7 +797,7 @@ class VarianceCalculator > { final TypeParameter typeParameter; - VarianceCalculator(this.typeParameter); + new(this.typeParameter); @override VarianceCalculationValue visitAuxiliaryType( @@ -1107,7 +1105,7 @@ bool hasGenericFunctionTypeAsTypeArgument(DartType type) { class _HasGenericFunctionTypeAsTypeArgumentVisitor extends DartTypeVisitor1 { - const _HasGenericFunctionTypeAsTypeArgumentVisitor(); + const new(); @override bool visitAuxiliaryType(AuxiliaryType node, bool isTypeArgument) { diff --git a/pkg/kernel/lib/src/constant_replacer.dart b/pkg/kernel/lib/src/constant_replacer.dart index ff1a8343725..edd8d9e76c5 100644 --- a/pkg/kernel/lib/src/constant_replacer.dart +++ b/pkg/kernel/lib/src/constant_replacer.dart @@ -7,7 +7,7 @@ import '../ast.dart'; /// Replacement visitor to clone a Constant if a subnode is replaced, and /// otherwise returns `null`. class ConstantReplacer implements ConstantVisitor { - ConstantReplacer(); + new(); final Map cache = {}; /// Like with Constants, `null` is used to signal that the [type] has not diff --git a/pkg/kernel/lib/src/dart_type_equivalence.dart b/pkg/kernel/lib/src/dart_type_equivalence.dart index 75ac09808c4..fd392261e28 100644 --- a/pkg/kernel/lib/src/dart_type_equivalence.dart +++ b/pkg/kernel/lib/src/dart_type_equivalence.dart @@ -15,7 +15,7 @@ class DartTypeEquivalence implements DartTypeVisitor1 { bool _atTopLevel = true; List> _alphaRenamingStack = []; - DartTypeEquivalence( + new( this.coreTypes, { this.equateTopTypes = false, this.ignoreAllNullabilities = false, diff --git a/pkg/kernel/lib/src/equivalence_helpers.dart b/pkg/kernel/lib/src/equivalence_helpers.dart index 0f851dc277d..58e9c3a71e6 100644 --- a/pkg/kernel/lib/src/equivalence_helpers.dart +++ b/pkg/kernel/lib/src/equivalence_helpers.dart @@ -6,7 +6,7 @@ part of 'equivalence.dart'; /// The node or property currently visited by the [EquivalenceVisitor]. abstract class State { - const State(); + const new(); State? get parent; } @@ -18,7 +18,7 @@ class NodeState extends State { final Node a; final Node b; - NodeState(this.a, this.b, [this.parent]); + new(this.a, this.b, [this.parent]); } /// State for visiting an AST property in [EquivalenceVisitor] @@ -27,7 +27,7 @@ class PropertyState extends State { final State? parent; final String name; - PropertyState(this.name, [this.parent]); + new(this.name, [this.parent]); } /// The state of the equivalence visitor. @@ -38,7 +38,7 @@ class CheckingState { /// If `true`, inequivalences are currently reported. final bool isAsserting; - CheckingState({ + new({ this.isAsserting = true, UnionFind? assumedReferences, State? currentState, @@ -149,10 +149,7 @@ class EquivalenceResult { final bool hasInequivalences; final List registeredInequivalences; - EquivalenceResult({ - this.hasInequivalences = false, - required this.registeredInequivalences, - }); + new({this.hasInequivalences = false, required this.registeredInequivalences}); bool get isEquivalent => !hasInequivalences && registeredInequivalences.isEmpty; @@ -173,7 +170,7 @@ class Inequivalence { final State state; final String message; - Inequivalence(this.state, this.message); + new(this.state, this.message); @override String toString() { @@ -251,12 +248,9 @@ class ReferenceName { final String? name; final String? uri; - ReferenceName.internal(this.kind, this.name, {this.parent, this.uri}); + new internal(this.kind, this.name, {this.parent, this.uri}); - factory ReferenceName.fromNamedNode( - NamedNode node, [ - ReferenceNameKind? memberKind, - ]) { + factory fromNamedNode(NamedNode node, [ReferenceNameKind? memberKind]) { if (node is Library) { return new ReferenceName.internal( ReferenceNameKind.Library, @@ -340,7 +334,7 @@ class ReferenceName { } } - factory ReferenceName.fromCanonicalName(CanonicalName canonicalName) { + factory fromCanonicalName(CanonicalName canonicalName) { List parents = []; CanonicalName? parent = canonicalName; while (parent != null) { diff --git a/pkg/kernel/lib/src/extension_type_erasure.dart b/pkg/kernel/lib/src/extension_type_erasure.dart index 5a08981c5be..9899587d29b 100644 --- a/pkg/kernel/lib/src/extension_type_erasure.dart +++ b/pkg/kernel/lib/src/extension_type_erasure.dart @@ -23,7 +23,7 @@ DartType? rawExtensionTypeErasure(DartType type) { /// /// The visitor returns `null` if the type wasn't changed. class _ExtensionTypeErasure extends ReplacementVisitor { - const _ExtensionTypeErasure(); + const new(); @override DartType? visitExtensionType(ExtensionType node, Variance variance) { diff --git a/pkg/kernel/lib/src/find_type_visitor.dart b/pkg/kernel/lib/src/find_type_visitor.dart index 34b9521a1e6..7af2658a28c 100644 --- a/pkg/kernel/lib/src/find_type_visitor.dart +++ b/pkg/kernel/lib/src/find_type_visitor.dart @@ -5,7 +5,7 @@ import '../ast.dart'; class FindTypeVisitor implements DartTypeVisitor { - const FindTypeVisitor(); + const new(); @override bool visitAuxiliaryType(AuxiliaryType node) { diff --git a/pkg/kernel/lib/src/future_value_type.dart b/pkg/kernel/lib/src/future_value_type.dart index 12e730f1c4e..00b5eb6388f 100644 --- a/pkg/kernel/lib/src/future_value_type.dart +++ b/pkg/kernel/lib/src/future_value_type.dart @@ -19,7 +19,7 @@ class FutureValueTypeVisitor implements DartTypeVisitor1 { final DartTypeVisitor1AuxiliaryFunction? unhandledTypeHandler; - const FutureValueTypeVisitor({this.unhandledTypeHandler}); + const new({this.unhandledTypeHandler}); DartType visit(DartType node, CoreTypes coreTypes) => node.accept1(this, coreTypes); diff --git a/pkg/kernel/lib/src/hierarchy_based_type_environment.dart b/pkg/kernel/lib/src/hierarchy_based_type_environment.dart index c3ce1a4870f..4be6361332b 100644 --- a/pkg/kernel/lib/src/hierarchy_based_type_environment.dart +++ b/pkg/kernel/lib/src/hierarchy_based_type_environment.dart @@ -16,7 +16,7 @@ class HierarchyBasedTypeEnvironment extends TypeEnvironment { @override final ClassHierarchy hierarchy; - HierarchyBasedTypeEnvironment(CoreTypes coreTypes, this.hierarchy) + new(CoreTypes coreTypes, this.hierarchy) : super.fromSubclass(coreTypes, hierarchy); @override diff --git a/pkg/kernel/lib/src/nnbd_top_merge.dart b/pkg/kernel/lib/src/nnbd_top_merge.dart index 37f578b9b7c..57e8408f5e0 100644 --- a/pkg/kernel/lib/src/nnbd_top_merge.dart +++ b/pkg/kernel/lib/src/nnbd_top_merge.dart @@ -44,7 +44,7 @@ DartType? nnbdTopMerge(CoreTypes coreTypes, DartType a, DartType b) { class NnbdTopMergeVisitor extends MergeVisitor { final CoreTypes coreTypes; - NnbdTopMergeVisitor(this.coreTypes); + new(this.coreTypes); @override Nullability? mergeNullability(Nullability a, Nullability b) { diff --git a/pkg/kernel/lib/src/node_creator.dart b/pkg/kernel/lib/src/node_creator.dart index 619462992b9..8125b1af859 100644 --- a/pkg/kernel/lib/src/node_creator.dart +++ b/pkg/kernel/lib/src/node_creator.dart @@ -71,7 +71,7 @@ class NodeCreator { List _neededSwitchCases = []; /// Creates a [NodeCreator] requested to create nodes of the specified kinds. - NodeCreator({ + new({ Iterable expressions = ExpressionKind.values, Iterable statements = StatementKind.values, Iterable dartTypes = DartTypeKind.values, diff --git a/pkg/kernel/lib/src/non_null.dart b/pkg/kernel/lib/src/non_null.dart index 911581420a3..33ecb8227b8 100644 --- a/pkg/kernel/lib/src/non_null.dart +++ b/pkg/kernel/lib/src/non_null.dart @@ -25,7 +25,7 @@ DartType computeNonNull(DartType type) { /// /// The visitor returns `null` if `NonNull(T) = T`. class _NonNullVisitor implements DartTypeVisitor { - const _NonNullVisitor(); + const new(); @override DartType? visitAuxiliaryType(AuxiliaryType node) { diff --git a/pkg/kernel/lib/src/norm.dart b/pkg/kernel/lib/src/norm.dart index c13682a6adc..e228d361e8a 100644 --- a/pkg/kernel/lib/src/norm.dart +++ b/pkg/kernel/lib/src/norm.dart @@ -40,7 +40,7 @@ Supertype normSupertype(CoreTypes coreTypes, Supertype supertype) { class _Norm extends ReplacementVisitor { final CoreTypes coreTypes; - _Norm(this.coreTypes); + new(this.coreTypes); @override DartType? visitInterfaceType(InterfaceType node, Variance variance) { diff --git a/pkg/kernel/lib/src/printer.dart b/pkg/kernel/lib/src/printer.dart index 91f20c42b94..24231052e37 100644 --- a/pkg/kernel/lib/src/printer.dart +++ b/pkg/kernel/lib/src/printer.dart @@ -74,7 +74,7 @@ class AstTextStrategy { /// printed. If exceeded, '...' is printed instead. final int? maxConstantDepth; - const AstTextStrategy({ + const new({ this.includeLibraryNamesInTypes = false, this.includeLibraryNamesInMembers = false, this.includeAuxiliaryProperties = false, @@ -102,7 +102,7 @@ class AstPrinter { late final Map _variableDeclarationNames = {}; late final Map _variableNames = {}; - AstPrinter(this._strategy); + new(this._strategy); bool get includeAuxiliaryProperties => _strategy.includeAuxiliaryProperties; @@ -680,7 +680,7 @@ class AstPrinter { class MarkingAstPrinter extends AstPrinter { Set markThis; - MarkingAstPrinter(super.strategy, this.markThis); + new(super.strategy, this.markThis); @override void writeStatement(Statement node) { diff --git a/pkg/kernel/lib/src/replacement_visitor.dart b/pkg/kernel/lib/src/replacement_visitor.dart index e0a38561545..0ddf6ea7604 100644 --- a/pkg/kernel/lib/src/replacement_visitor.dart +++ b/pkg/kernel/lib/src/replacement_visitor.dart @@ -8,7 +8,7 @@ import '../type_algebra.dart'; /// Helper visitor that clones a type if a nested type is replaced, and /// otherwise returns `null`. class ReplacementVisitor implements DartTypeVisitor1 { - const ReplacementVisitor(); + const new(); Nullability? visitNullability(DartType node) => null; diff --git a/pkg/kernel/lib/src/tool/check_equivalence.dart b/pkg/kernel/lib/src/tool/check_equivalence.dart index 475ea38621c..de1ded1792f 100644 --- a/pkg/kernel/lib/src/tool/check_equivalence.dart +++ b/pkg/kernel/lib/src/tool/check_equivalence.dart @@ -121,7 +121,7 @@ class Strategy extends EquivalenceStrategy { final bool unorderedConstructors; final bool unorderedAnnotations; - Strategy({ + new({ required this.unorderedLibraries, required this.unorderedLibraryDependencies, required this.unorderedAdditionalExports, diff --git a/pkg/kernel/lib/src/tool/find_referenced_libraries.dart b/pkg/kernel/lib/src/tool/find_referenced_libraries.dart index 14824acea85..5f3e984d70f 100644 --- a/pkg/kernel/lib/src/tool/find_referenced_libraries.dart +++ b/pkg/kernel/lib/src/tool/find_referenced_libraries.dart @@ -29,7 +29,7 @@ class _LibraryCollector extends RecursiveVisitor { final bool collectViaReferencesToo; Set allSeenLibraries = {}; - _LibraryCollector({required this.collectViaReferencesToo}); + new({required this.collectViaReferencesToo}); @override void defaultNode(Node node) { diff --git a/pkg/kernel/lib/src/types.dart b/pkg/kernel/lib/src/types.dart index 50aa17824c1..87ab6007b6c 100644 --- a/pkg/kernel/lib/src/types.dart +++ b/pkg/kernel/lib/src/types.dart @@ -19,7 +19,7 @@ class Types with StandardBounds { @override final ClassHierarchyBase hierarchy; - Types(this.hierarchy); + new(this.hierarchy); @override CoreTypes get coreTypes => hierarchy.coreTypes; diff --git a/pkg/kernel/lib/src/unaliasing.dart b/pkg/kernel/lib/src/unaliasing.dart index 308efda41e2..a5ef3892962 100644 --- a/pkg/kernel/lib/src/unaliasing.dart +++ b/pkg/kernel/lib/src/unaliasing.dart @@ -59,7 +59,7 @@ List? rawUnaliasTypes(List types) { /// If [legacyEraseAliases] is `true`, the unaliased types will be legacy /// erased. This used when the [TypedefType] was used in a legacy library. class _Unalias extends ReplacementVisitor { - const _Unalias(); + const new(); @override DartType visitTypedefType(TypedefType node, Variance variance) { diff --git a/pkg/kernel/lib/src/union_find.dart b/pkg/kernel/lib/src/union_find.dart index 7d26dc7012f..c72939de602 100644 --- a/pkg/kernel/lib/src/union_find.dart +++ b/pkg/kernel/lib/src/union_find.dart @@ -12,13 +12,13 @@ class UnionFindNode { final T value; UnionFindNode? parent; - UnionFindNode(this.value); + new(this.value); } class UnionFind { final Map> _nodeMap; - UnionFind({bool useIdentity = false}) + new({bool useIdentity = false}) : _nodeMap = useIdentity ? new LinkedHashMap.identity() : {}; UnionFindNode operator [](T value) => diff --git a/pkg/kernel/lib/target/targets.dart b/pkg/kernel/lib/target/targets.dart index d9c52eb72d4..f73ad0b083a 100644 --- a/pkg/kernel/lib/target/targets.dart +++ b/pkg/kernel/lib/target/targets.dart @@ -31,7 +31,7 @@ class TargetFlags { /// by their target platform. final bool includeUnsupportedPlatformLibraryStubs; - const TargetFlags({ + const new({ this.trackCreationLocations = false, this.supportMirrors = true, this.isClosureContextLoweringEnabled = false, @@ -101,7 +101,7 @@ enum NumberSemantics { // Backend specific constant evaluation behavior class ConstantsBackend { - const ConstantsBackend({this.keepLocals = true}); + const new({this.keepLocals = true}); /// Lowering of a list constant to a backend-specific representation. Constant lowerListConstant(ListConstant constant) => constant; @@ -259,7 +259,7 @@ abstract class DartLibrarySupport { /// [DartLibrarySupport] that only relies on the "supported" property of /// the libraries specification. class DefaultDartLibrarySupport implements DartLibrarySupport { - const DefaultDartLibrarySupport(); + const new(); @override bool computeDartLibrarySupport( @@ -274,10 +274,7 @@ class CustomizedDartLibrarySupport implements DartLibrarySupport { final Set supported; final Set unsupported; - const CustomizedDartLibrarySupport({ - this.supported = const {}, - this.unsupported = const {}, - }); + const new({this.supported = const {}, this.unsupported = const {}}); @override bool computeDartLibrarySupport( @@ -640,17 +637,14 @@ class NoneConstantsBackend extends ConstantsBackend { @override final bool supportsUnevaluatedConstants; - const NoneConstantsBackend({ - required this.supportsUnevaluatedConstants, - super.keepLocals, - }); + const new({required this.supportsUnevaluatedConstants, super.keepLocals}); } class NoneTarget extends Target { @override final TargetFlags flags; - NoneTarget(this.flags); + new(this.flags); @override int get enabledLateLowerings => LateLowering.none; @@ -827,7 +821,7 @@ class TestTargetFlags extends TargetFlags { final Set supportedDartLibraries; final Set unsupportedDartLibraries; - const TestTargetFlags({ + const new({ bool trackCreationLocations = false, this.forceLateLoweringsForTesting, this.forceLateLoweringSentinelForTesting, @@ -882,7 +876,7 @@ class TestDartLibrarySupport implements DartLibrarySupport { final DartLibrarySupport delegate; final TestTargetFlags flags; - TestDartLibrarySupport(this.delegate, this.flags); + new(this.delegate, this.flags); @override bool computeDartLibrarySupport( @@ -904,7 +898,7 @@ class TestDartLibrarySupport implements DartLibrarySupport { class TargetWrapper extends Target { final Target _target; - TargetWrapper(this._target); + new(this._target); @override TargetFlags get flags => _target.flags; @@ -1122,7 +1116,7 @@ class TestTargetWrapper extends TargetWrapper with TestTargetMixin { @override final TestTargetFlags flags; - TestTargetWrapper(Target target, this.flags) : super(target); + new(Target target, this.flags) : super(target); } /// Extends a Target to transform outlines to meet the requirements diff --git a/pkg/kernel/lib/testing/type_parser.dart b/pkg/kernel/lib/testing/type_parser.dart index fe77c4895dc..366dcd91012 100644 --- a/pkg/kernel/lib/testing/type_parser.dart +++ b/pkg/kernel/lib/testing/type_parser.dart @@ -58,7 +58,7 @@ class ParsedNamedType extends ParsedType { final ParsedNullability parsedNullability; - ParsedNamedType(this.name, this.arguments, this.parsedNullability); + new(this.name, this.arguments, this.parsedNullability); @override String toString() { @@ -82,7 +82,7 @@ class ParsedNamedType extends ParsedType { abstract class ParsedDeclaration extends ParsedType { final String name; - ParsedDeclaration(this.name); + new(this.name); } class ParsedClass extends ParsedDeclaration { @@ -92,7 +92,7 @@ class ParsedClass extends ParsedDeclaration { final List interfaces; final ParsedFunctionType? callableType; - ParsedClass( + new( String name, this.typeVariables, this.supertype, @@ -139,7 +139,7 @@ class ParsedExtension extends ParsedDeclaration { final List typeVariables; final ParsedNamedType onType; - ParsedExtension(String name, this.typeVariables, this.onType) : super(name); + new(String name, this.typeVariables, this.onType) : super(name); @override String toString() { @@ -168,7 +168,7 @@ class ParsedTypedef extends ParsedDeclaration { final ParsedType type; - ParsedTypedef(String name, this.typeVariables, this.type) : super(name); + new(String name, this.typeVariables, this.type) : super(name); @override String toString() { @@ -198,7 +198,7 @@ class ParsedExtensionTypeDeclaration extends ParsedDeclaration { final List interfaces; - ParsedExtensionTypeDeclaration( + new( String name, this.typeVariables, this.declaredRepresentationType, @@ -240,7 +240,7 @@ class ParsedFunctionType extends ParsedType { final ParsedNullability parsedNullability; - ParsedFunctionType( + new( this.typeVariables, this.returnType, this.arguments, @@ -274,7 +274,7 @@ class ParsedRecordType extends ParsedType { final List named; final ParsedNullability parsedNullability; - ParsedRecordType(this.positional, this.named, this.parsedNullability); + new(this.positional, this.named, this.parsedNullability); @override String toString() { @@ -318,7 +318,7 @@ class ParsedTypeVariable extends ParsedType { final ParsedType? bound; - ParsedTypeVariable(this.name, this.bound); + new(this.name, this.bound); @override String toString() { @@ -341,7 +341,7 @@ class ParsedIntersectionType extends ParsedType { final ParsedType b; - ParsedIntersectionType(this.a, this.b); + new(this.a, this.b); @override String toString() { @@ -363,7 +363,7 @@ class ParsedArguments { final List positional; final List named; - ParsedArguments(this.required, this.positional, this.named) + new(this.required, this.positional, this.named) : assert(positional.isEmpty || named.isEmpty); @override @@ -398,7 +398,7 @@ class ParsedNamedArgument { final ParsedType type; final String name; - ParsedNamedArgument(this.isRequired, this.type, this.name); + new(this.isRequired, this.type, this.name); @override String toString() { @@ -420,7 +420,7 @@ class Token { Token? next; - Token(this.charOffset, this.text, {this.isIdentifier = false}); + new(this.charOffset, this.text, {this.isIdentifier = false}); bool get isEof => text == null; } @@ -430,7 +430,7 @@ class Parser { String source; - Parser(this.peek, this.source); + new(this.peek, this.source); bool get atEof => peek.isEof; diff --git a/pkg/kernel/lib/testing/type_parser_environment.dart b/pkg/kernel/lib/testing/type_parser_environment.dart index 4609abaa5b8..3101d964aa9 100644 --- a/pkg/kernel/lib/testing/type_parser_environment.dart +++ b/pkg/kernel/lib/testing/type_parser_environment.dart @@ -102,7 +102,7 @@ class Env { late TypeParserEnvironment _libraryEnvironment; - Env(String source) { + new(String source) { Uri libraryUri = Uri.parse('memory:main.dart'); Uri coreUri = Uri.parse("dart:core"); TypeParserEnvironment coreEnvironment = new TypeParserEnvironment( @@ -228,7 +228,7 @@ class TypeParserEnvironment { final List pendingNullabilities = []; - TypeParserEnvironment(this.uri, this.fileUri, [this._parent]); + new(this.uri, this.fileUri, [this._parent]); @override String toString() { @@ -341,7 +341,7 @@ class TypeParserEnvironment { class _KernelFromParsedType implements Visitor { final Map? additionalTypes; // Can be null. - const _KernelFromParsedType({this.additionalTypes}); + const new({this.additionalTypes}); DartType _parseType(ParsedType type, TypeParserEnvironment environment) { return type.accept(this, environment) @@ -860,12 +860,12 @@ class ParameterEnvironment { final List parameters; final TypeParserEnvironment environment; - const ParameterEnvironment(this.parameters, this.environment); + const new(this.parameters, this.environment); } class FunctionTypeParameterEnvironment { final List parameters; final TypeParserEnvironment environment; - const FunctionTypeParameterEnvironment(this.parameters, this.environment); + const new(this.parameters, this.environment); } diff --git a/pkg/kernel/lib/text/ast_to_text.dart b/pkg/kernel/lib/text/ast_to_text.dart index fdb2431862c..2c77f743707 100644 --- a/pkg/kernel/lib/text/ast_to_text.dart +++ b/pkg/kernel/lib/text/ast_to_text.dart @@ -24,14 +24,14 @@ class NormalNamer extends Namer { @override final String prefix; - NormalNamer(this.prefix); + new(this.prefix); } class ConstantNamer extends RecursiveVisitor with Namer { @override final String prefix; - ConstantNamer(this.prefix); + new(this.prefix); @override String getName(Constant constant) { @@ -266,7 +266,7 @@ class Printer extends VisitorDefault with VisitorVoidMixin { static final int SYMBOL = 2; int state = SPACE; - Printer( + new( this.sink, { NameSystem? syntheticNames, this.showOffsets = false, diff --git a/pkg/kernel/lib/text/text_reader.dart b/pkg/kernel/lib/text/text_reader.dart index 4d881a8c61d..82536ccb9f1 100644 --- a/pkg/kernel/lib/text/text_reader.dart +++ b/pkg/kernel/lib/text/text_reader.dart @@ -27,7 +27,7 @@ class TextIterator implements Iterator { final String input; int index; - TextIterator(this.input, this.index); + new(this.input, this.index); // Consume spaces. void skipWhitespace() { diff --git a/pkg/kernel/lib/transformations/track_widget_constructor_locations.dart b/pkg/kernel/lib/transformations/track_widget_constructor_locations.dart index f5bf065547a..375c3b54b18 100644 --- a/pkg/kernel/lib/transformations/track_widget_constructor_locations.dart +++ b/pkg/kernel/lib/transformations/track_widget_constructor_locations.dart @@ -135,8 +135,7 @@ class _WidgetCallSiteTransformer extends Transformer { /// of the library. Library? _currentLibrary; - _WidgetCallSiteTransformer({required WidgetCreatorTracker tracker}) - : _tracker = tracker; + new({required WidgetCreatorTracker tracker}) : _tracker = tracker; /// Builds a call to the const constructor of the _Location /// object specifying the location where a constructor call was made and @@ -905,7 +904,7 @@ class _TrackingClasses { final Class locationClass; final String locationFieldName; - _TrackingClasses({ + new({ required this.hasCreationLocationClass, required this.locationClass, required this.locationFieldName, diff --git a/pkg/kernel/lib/type_algebra.dart b/pkg/kernel/lib/type_algebra.dart index acc16fad2e7..bedb3deaf0c 100644 --- a/pkg/kernel/lib/type_algebra.dart +++ b/pkg/kernel/lib/type_algebra.dart @@ -166,11 +166,7 @@ class FreshTypeParameters { /// Substitution from the original type parameters to [freshTypeArguments]. final Substitution substitution; - FreshTypeParameters( - this.freshTypeParameters, - this.freshTypeArguments, - this.substitution, - ); + new(this.freshTypeParameters, this.freshTypeArguments, this.substitution); DartType substitute(DartType type) => substitution.substituteType(type); } @@ -254,11 +250,7 @@ class FreshStructuralParametersFromTypeParameters { /// Substitution from the original type parameters to [freshTypeArguments]. final Substitution substitution; - FreshStructuralParametersFromTypeParameters( - this.freshTypeParameters, - this.freshTypeArguments, - this.substitution, - ); + new(this.freshTypeParameters, this.freshTypeArguments, this.substitution); DartType substitute(DartType type) => substitution.substituteType(type); } @@ -318,11 +310,7 @@ class FreshTypeParametersFromStructuralParameters { /// Substitution from the original type parameters to [freshTypeArguments]. final FunctionTypeInstantiator instantiator; - FreshTypeParametersFromStructuralParameters( - this.freshTypeParameters, - this.freshTypeArguments, - this.instantiator, - ); + new(this.freshTypeParameters, this.freshTypeArguments, this.instantiator); DartType substitute(DartType type) => instantiator.substitute(type); } @@ -480,11 +468,7 @@ class FreshStructuralParameters { /// Substitution from the original type parameters to [freshTypeArguments]. final FunctionTypeInstantiator instantiator; - FreshStructuralParameters( - this.freshTypeParameters, - this.freshTypeArguments, - this.instantiator, - ); + new(this.freshTypeParameters, this.freshTypeArguments, this.instantiator); DartType substitute(DartType type) => instantiator.substitute(type); @@ -511,7 +495,7 @@ class FreshStructuralParameters { // ------------------------------------------------------------------------ abstract class Substitution { - const Substitution(); + const new(); static const Substitution empty = _NullSubstitution.instance; @@ -788,7 +772,7 @@ class _AllFreeTypeVariablesVisitor implements DartTypeVisitor { class _NullSubstitution extends Substitution { static const _NullSubstitution instance = const _NullSubstitution(); - const _NullSubstitution(); + const new(); @override DartType getSubstitute(TypeParameter parameter, bool upperBound) { @@ -809,7 +793,7 @@ class _MapSubstitution extends Substitution { final Map upper; final Map lower; - _MapSubstitution(this.upper, this.lower); + new(this.upper, this.lower); @override DartType? getSubstitute(TypeParameter parameter, bool upperBound) { @@ -824,7 +808,7 @@ class _SingletonSubstitution extends Substitution { final TypeParameter typeParameter; final DartType type; - _SingletonSubstitution(this.typeParameter, this.type); + new(this.typeParameter, this.type); @override DartType? getSubstitute(TypeParameter parameter, bool upperBound) { @@ -838,7 +822,7 @@ class _SingletonSubstitution extends Substitution { class _TopSubstitutor extends _TypeSubstitutor { final Substitution substitution; - _TopSubstitutor(this.substitution, bool contravariant) : super(null) { + new(this.substitution, bool contravariant) : super(null) { if (contravariant) { invertVariance(); } @@ -858,7 +842,7 @@ class _TopSubstitutor extends _TypeSubstitutor { class _TypeDeclarationBottomSubstitution extends Substitution { final GenericDeclaration declaration; - _TypeDeclarationBottomSubstitution(this.declaration); + new(this.declaration); @override DartType? getSubstitute(TypeParameter parameter, bool upperBound) { @@ -872,7 +856,7 @@ class _TypeDeclarationBottomSubstitution extends Substitution { class _CombinedSubstitution extends Substitution { final Substitution first, second; - _CombinedSubstitution(this.first, this.second); + new(this.first, this.second); @override DartType? getSubstitute(TypeParameter parameter, bool upperBound) { @@ -887,10 +871,8 @@ class _InnerTypeSubstitutor extends _SubstitutorBase { final Map substitution = {}; - _InnerTypeSubstitutor({ - required _SubstitutorBase? outer, - required bool covariantContext, - }) : super(outer: outer, covariantContext: covariantContext); + new({required _SubstitutorBase? outer, required bool covariantContext}) + : super(outer: outer, covariantContext: covariantContext); @override DartType? lookup(TypeParameter parameter, bool upperBound) { @@ -1204,7 +1186,7 @@ abstract class _SubstitutorBase implements DartTypeVisitor { /// check quickly if anything happened in a substitution. int useCounter = 0; - _SubstitutorBase({required this.outer, required this.covariantContext}); + new({required this.outer, required this.covariantContext}); DartType? lookup(TypeParameter parameter, bool upperBound); @@ -1269,7 +1251,7 @@ abstract class _SubstitutorBase implements DartTypeVisitor { } abstract class _TypeSubstitutor extends _SubstitutorBase { - _TypeSubstitutor(_SubstitutorBase? outer) + new(_SubstitutorBase? outer) : super( outer: outer, covariantContext: outer == null ? true : outer.covariantContext, @@ -1467,19 +1449,15 @@ class FunctionTypeInstantiator implements DartTypeVisitor { Map substitutionMap; FunctionTypeInstantiator? outer; - FunctionTypeInstantiator.fromMap(this.substitutionMap, {this.outer}); + new fromMap(this.substitutionMap, {this.outer}); - FunctionTypeInstantiator.fromIterables( - List from, - List to, - ) : this.fromMap( + new fromIterables(List from, List to) + : this.fromMap( new Map.fromIterables(from, to), ); - FunctionTypeInstantiator.fromInstantiation( - FunctionType functionType, - List arguments, - ) : this.fromIterables(functionType.typeParameters, arguments); + new fromInstantiation(FunctionType functionType, List arguments) + : this.fromIterables(functionType.typeParameters, arguments); static FunctionType instantiate( FunctionType functionType, @@ -1775,7 +1753,7 @@ class _OccurrenceVisitor extends FindTypeVisitor { /// implementer of [DartType] is encountered. final DartTypeVisitorAuxiliaryFunction? unhandledTypeHandler; - _OccurrenceVisitor(this.variables, {this.unhandledTypeHandler}); + new(this.variables, {this.unhandledTypeHandler}); bool visit(DartType type) => type.accept(this); @@ -1827,10 +1805,7 @@ class _StructuralParameterOccurrenceVisitor implements FindTypeVisitor { /// implementer of [DartType] is encountered. final DartTypeVisitorAuxiliaryFunction? unhandledTypeHandler; - _StructuralParameterOccurrenceVisitor( - this.variables, { - this.unhandledTypeHandler, - }); + new(this.variables, {this.unhandledTypeHandler}); bool visit(DartType node) => node.accept(this); @@ -1925,7 +1900,7 @@ class _StructuralParameterOccurrenceVisitor implements FindTypeVisitor { class _FreeFunctionTypeVariableVisitor extends FindTypeVisitor { final Set variables = new Set(); - _FreeFunctionTypeVariableVisitor(); + new(); bool visit(DartType node) => node.accept(this); @@ -1946,7 +1921,7 @@ class _FreeFunctionTypeVariableVisitor extends FindTypeVisitor { class _FreeTypeVariableVisitor extends FindTypeVisitor { final Set boundVariables; - _FreeTypeVariableVisitor({Set? boundVariables}) + new({Set? boundVariables}) : this.boundVariables = boundVariables ?? {}; bool visit(DartType type) => type.accept(this); @@ -2006,7 +1981,7 @@ bool isPrimitiveDartType(DartType type) { /// to its purpose. The reason for having a visitor is to make the need for an /// update visible when a new implementer of [DartType] is introduced in Kernel. class _PrimitiveTypeVerifier implements DartTypeVisitor { - const _PrimitiveTypeVerifier(); + const new(); @override bool visitAuxiliaryType(AuxiliaryType node) { @@ -2095,7 +2070,7 @@ DartType unwrapNullabilityConstructor(DartType type) { /// Implementing the function as a visitor makes the necessity of supporting a /// new implementation of [DartType] visible at compile time. class _NullabilityConstructorUnwrapper implements DartTypeVisitor { - const _NullabilityConstructorUnwrapper(); + const new(); @override DartType visitAuxiliaryType(AuxiliaryType node) { @@ -2192,7 +2167,7 @@ abstract class TypeVariableEliminatorBase extends ReplacementVisitor { final CoreTypes coreTypes; late bool _isLeastClosure; - TypeVariableEliminatorBase({required this.coreTypes}); + new({required this.coreTypes}); bool containsTypeVariablesToEliminate(DartType type); @@ -2287,7 +2262,7 @@ class TypeParameterEliminator extends TypeVariableEliminatorBase { final Set nominalEliminationTargets; final DartTypeVisitorAuxiliaryFunction? unhandledTypeHandler; - TypeParameterEliminator({ + new({ required this.structuralEliminationTargets, required this.nominalEliminationTargets, required CoreTypes coreTypes, @@ -2332,8 +2307,7 @@ class TypeParameterEliminator extends TypeVariableEliminatorBase { class FreeTypeParameterEliminator extends TypeVariableEliminatorBase { Set _boundVariables = {}; - FreeTypeParameterEliminator({required CoreTypes coreTypes}) - : super(coreTypes: coreTypes); + new({required CoreTypes coreTypes}) : super(coreTypes: coreTypes); @override DartType? visitFunctionType(FunctionType node, Variance variance) { @@ -2433,7 +2407,7 @@ bool isTypeWithoutNullabilityMarker(DartType type) { } class _NullabilityMarkerDetector implements DartTypeVisitor { - const _NullabilityMarkerDetector(); + const new(); @override bool visitAuxiliaryType(AuxiliaryType node) { diff --git a/pkg/kernel/lib/type_checker.dart b/pkg/kernel/lib/type_checker.dart index 8d91a04f874..1ad9b813a70 100644 --- a/pkg/kernel/lib/type_checker.dart +++ b/pkg/kernel/lib/type_checker.dart @@ -24,7 +24,7 @@ abstract class TypeChecker { Library? currentLibrary; InterfaceType? currentThisType; - TypeChecker(this.coreTypes, this.hierarchy, {this.ignoreSdk = true}) + new(this.coreTypes, this.hierarchy, {this.ignoreSdk = true}) : environment = new TypeEnvironment(coreTypes, hierarchy); void checkComponent(Component component) { @@ -149,7 +149,7 @@ class TypeCheckingVisitor DartType? currentYieldType; AsyncMarker currentAsyncMarker = AsyncMarker.Sync; - TypeCheckingVisitor(this.checker, this.environment, this.hierarchy); + new(this.checker, this.environment, this.hierarchy); void checkAssignable(TreeNode where, DartType from, DartType to) { checker.checkAssignable(where, from, to); diff --git a/pkg/kernel/lib/type_environment.dart b/pkg/kernel/lib/type_environment.dart index d4a7e0ca9fa..cb9553ddecc 100644 --- a/pkg/kernel/lib/type_environment.dart +++ b/pkg/kernel/lib/type_environment.dart @@ -20,10 +20,9 @@ abstract class TypeEnvironment extends Types { @override final CoreTypes coreTypes; - TypeEnvironment.fromSubclass(this.coreTypes, ClassHierarchyBase base) - : super(base); + new fromSubclass(this.coreTypes, ClassHierarchyBase base) : super(base); - factory TypeEnvironment(CoreTypes coreTypes, ClassHierarchy hierarchy) { + factory(CoreTypes coreTypes, ClassHierarchy hierarchy) { return new HierarchyBasedTypeEnvironment(coreTypes, hierarchy); } @@ -596,14 +595,14 @@ class IsSubtypeOf { final DartType? supertype; - const IsSubtypeOf._internal(bool isSuccess, this.subtype, this.supertype) + const new _internal(bool isSuccess, this.subtype, this.supertype) : _isSuccess = isSuccess; /// Subtype check succeeds. - const IsSubtypeOf.success() : this._internal(true, null, null); + const new success() : this._internal(true, null, null); /// Subtype check fails. - const IsSubtypeOf.failure() : this._internal(false, null, null); + const new failure() : this._internal(false, null, null); /// Checks if two types are in relation based solely on their nullabilities. /// @@ -615,10 +614,7 @@ class IsSubtypeOf { /// is the result of a subtype check on the arguments `int` and `num`, and /// `Rn` is the result of [IsSubtypeOf.basedSolelyOnNullabilities] on the /// types `List?` and `List*`. - factory IsSubtypeOf.basedSolelyOnNullabilities( - DartType subtype, - DartType supertype, - ) { + factory basedSolelyOnNullabilities(DartType subtype, DartType supertype) { if (subtype is InvalidType) { if (supertype is InvalidType) { return const IsSubtypeOf.success(); @@ -634,7 +630,7 @@ class IsSubtypeOf { /// Checks if two types are in relation based solely on their nullabilities /// and where the caller knows that neither type is a `InvalidType`. - factory IsSubtypeOf.basedSolelyOnNullabilitiesNotInvalidType( + factory basedSolelyOnNullabilitiesNotInvalidType( DartType subtype, DartType supertype, ) { @@ -803,7 +799,7 @@ abstract class StaticTypeContext { /// Creates a static type context for computing static types in the body /// of [member]. - factory StaticTypeContext( + factory( Member member, TypeEnvironment typeEnvironment, { StaticTypeCache cache, @@ -811,7 +807,7 @@ abstract class StaticTypeContext { /// Creates a static type context for computing static types of annotations /// in [library]. - factory StaticTypeContext.forAnnotations( + factory forAnnotations( Library library, TypeEnvironment typeEnvironment, { StaticTypeCache cache, @@ -855,23 +851,20 @@ class StaticTypeContextImpl implements StaticTypeContext { /// Creates a static type context for computing static types in the body /// of [member]. - StaticTypeContextImpl( - Member member, - TypeEnvironment typeEnvironment, { - StaticTypeCache? cache, - }) : this.direct( - member.enclosingLibrary, - typeEnvironment, - thisType: member.enclosingClass?.getThisType( - typeEnvironment.coreTypes, - member.enclosingLibrary.nonNullable, - ), - cache: cache, - ); + new(Member member, TypeEnvironment typeEnvironment, {StaticTypeCache? cache}) + : this.direct( + member.enclosingLibrary, + typeEnvironment, + thisType: member.enclosingClass?.getThisType( + typeEnvironment.coreTypes, + member.enclosingLibrary.nonNullable, + ), + cache: cache, + ); /// Creates a static type context for computing static types in the body of /// a member, provided the enclosing [_library] and [thisType]. - StaticTypeContextImpl.direct( + new direct( this._library, this.typeEnvironment, { this.thisType, @@ -880,7 +873,7 @@ class StaticTypeContextImpl implements StaticTypeContext { /// Creates a static type context for computing static types of annotations /// in [library]. - StaticTypeContextImpl.forAnnotations( + new forAnnotations( Library library, TypeEnvironment typeEnvironment, { StaticTypeCache? cache, @@ -937,15 +930,15 @@ abstract class StatefulStaticTypeContext implements StaticTypeContext { /// Creates a [StatefulStaticTypeContext] that supports entering multiple /// libraries and/or members successively. - factory StatefulStaticTypeContext.stacked(TypeEnvironment typeEnvironment) = + factory stacked(TypeEnvironment typeEnvironment) = _StackedStatefulStaticTypeContext; /// Creates a [StatefulStaticTypeContext] that only supports entering one /// library and/or member at a time. - factory StatefulStaticTypeContext.flat(TypeEnvironment typeEnvironment) = + factory flat(TypeEnvironment typeEnvironment) = _FlatStatefulStaticTypeContext; - StatefulStaticTypeContext._internal(this.typeEnvironment); + new _internal(this.typeEnvironment); /// Updates the [nonNullable] and [thisType] to match static type context for /// the member [node]. @@ -980,8 +973,7 @@ class _FlatStatefulStaticTypeContext extends StatefulStaticTypeContext { Library? _currentLibrary; Member? _currentMember; - _FlatStatefulStaticTypeContext(TypeEnvironment typeEnvironment) - : super._internal(typeEnvironment); + new(TypeEnvironment typeEnvironment) : super._internal(typeEnvironment); @override Library get enclosingLibrary => _library; @@ -1088,8 +1080,7 @@ class _StackedStatefulStaticTypeContext extends StatefulStaticTypeContext { final List<_StaticTypeContextState> _contextStack = <_StaticTypeContextState>[]; - _StackedStatefulStaticTypeContext(TypeEnvironment typeEnvironment) - : super._internal(typeEnvironment); + new(TypeEnvironment typeEnvironment) : super._internal(typeEnvironment); @override Library get enclosingLibrary => _library; @@ -1192,7 +1183,7 @@ class _StaticTypeContextState { final Library _library; final InterfaceType? _thisType; - _StaticTypeContextState(this._node, this._library, this._thisType); + new(this._node, this._library, this._thisType); } /// Describes whether only performing a shape check is sufficient for a diff --git a/pkg/kernel/lib/util/graph.dart b/pkg/kernel/lib/util/graph.dart index d38bcd1a37d..6f7e6889720 100644 --- a/pkg/kernel/lib/util/graph.dart +++ b/pkg/kernel/lib/util/graph.dart @@ -22,7 +22,7 @@ class LibraryGraph implements Graph { final Iterable libraries; final Library? coreLibrary; - LibraryGraph(this.libraries, {this.coreLibrary}); + new(this.libraries, {this.coreLibrary}); @override Iterable get vertices => libraries; @@ -116,7 +116,7 @@ class StrongComponentGraph implements Graph> { final Map> _elementToComponentMap = {}; final Map, Set>> _neighborsMap = {}; - StrongComponentGraph(this.subgraph, this.components) { + new(this.subgraph, this.components) { for (List component in components) { for (T element in component) { _elementToComponentMap[element] = component; diff --git a/pkg/kernel/lib/verifier.dart b/pkg/kernel/lib/verifier.dart index c97ba75d2a9..eb31800944c 100644 --- a/pkg/kernel/lib/verifier.dart +++ b/pkg/kernel/lib/verifier.dart @@ -48,7 +48,7 @@ enum VerificationStage { /// Interface that defines how the AST is verified. class Verification { - const Verification(); + const new(); /// Returns `true` if [node] is allowed to have no file offset. bool allowNoFileOffset(VerificationStage stage, TreeNode node) { @@ -79,7 +79,7 @@ void verifyComponent( } class VerificationErrorListener { - const VerificationErrorListener(); + const new(); void reportError( String details, { @@ -100,7 +100,7 @@ class VerificationError { final String details; - VerificationError(this.context, this.node, this.details); + new(this.context, this.node, this.details); @override String toString() { @@ -200,7 +200,7 @@ class VerifyingVisitor extends RecursiveResultVisitor { ); } - VerifyingVisitor( + new( this.target, this.stage, { required this.skipPlatform, @@ -2277,7 +2277,7 @@ class VerifyGetStaticType extends RecursiveVisitor { Member? currentMember; final StatefulStaticTypeContext _staticTypeContext; - VerifyGetStaticType(this.env) + new(this.env) : _staticTypeContext = new StatefulStaticTypeContext.stacked(env); @override @@ -2359,7 +2359,7 @@ class AllowedTypes implements DartTypeVisitor { final bool inConstant; - const AllowedTypes({required this.inConstant}); + const new({required this.inConstant}); @override bool visitAuxiliaryType(AuxiliaryType node) => false; diff --git a/pkg/kernel/lib/visitor.dart b/pkg/kernel/lib/visitor.dart index 5262b73dda7..0e9e1550acd 100644 --- a/pkg/kernel/lib/visitor.dart +++ b/pkg/kernel/lib/visitor.dart @@ -9,7 +9,7 @@ import 'dart:collection'; import 'ast.dart'; abstract class ExpressionVisitor { - const ExpressionVisitor(); + const new(); R visitAuxiliaryExpression(AuxiliaryExpression node); R visitInvalidExpression(InvalidExpression node); @@ -310,7 +310,7 @@ mixin PatternVisitorDefaultMixin implements PatternVisitor { } abstract class StatementVisitor { - const StatementVisitor(); + const new(); R visitAuxiliaryStatement(AuxiliaryStatement node); @@ -422,7 +422,7 @@ mixin StatementVisitorDefaultMixin implements StatementVisitor { } abstract class VariableVisitor { - const VariableVisitor(); + const new(); R visitLegacyVariable(LegacyVariable node); R visitPositionalParameter(PositionalParameter node); @@ -458,7 +458,7 @@ mixin VariableVisitorDefaultMixin implements VariableVisitor { } abstract class MemberVisitor { - const MemberVisitor(); + const new(); R visitConstructor(Constructor node); R visitProcedure(Procedure node); @@ -479,7 +479,7 @@ mixin MemberVisitorDefaultMixin implements MemberVisitor { } abstract class MemberVisitor1 { - const MemberVisitor1(); + const new(); R visitConstructor(Constructor node, A arg); R visitProcedure(Procedure node, A arg); @@ -500,7 +500,7 @@ mixin MemberVisitor1DefaultMixin implements MemberVisitor1 { } abstract class InitializerVisitor { - const InitializerVisitor(); + const new(); R visitAuxiliaryInitializer(AuxiliaryInitializer node); R visitInvalidInitializer(InvalidInitializer node); @@ -536,7 +536,7 @@ mixin InitializerVisitorDefaultMixin implements InitializerVisitor { } abstract class InitializerVisitor1 { - const InitializerVisitor1(); + const new(); R visitAuxiliaryInitializer(AuxiliaryInitializer node, A arg); R visitInvalidInitializer(InvalidInitializer node, A arg); @@ -584,7 +584,7 @@ abstract class TreeVisitor VariableVisitor, MemberVisitor, InitializerVisitor { - const TreeVisitor(); + const new(); // Classes R visitClass(Class node); @@ -686,7 +686,7 @@ abstract class TreeVisitorDefault MemberVisitorDefaultMixin, TreeVisitorDefaultMixin implements TreeVisitor { - const TreeVisitorDefault(); + const new(); @override R defaultExpression(Expression node) => defaultTreeNode(node); @@ -710,7 +710,7 @@ abstract class TreeVisitor1 VariableVisitor1, MemberVisitor1, InitializerVisitor1 { - const TreeVisitor1(); + const new(); // Classes R visitClass(Class node, A arg); @@ -820,7 +820,7 @@ abstract class TreeVisitor1Default InitializerVisitor1DefaultMixin, MemberVisitor1DefaultMixin implements TreeVisitor1 { - const TreeVisitor1Default(); + const new(); @override R defaultExpression(Expression node, A arg) => defaultTreeNode(node, arg); @@ -840,7 +840,7 @@ typedef DartTypeVisitorAuxiliaryFunction = R Function(AuxiliaryType node, R Function(AuxiliaryType node) recursor); abstract class DartTypeVisitor { - const DartTypeVisitor(); + const new(); R visitAuxiliaryType(AuxiliaryType node); R visitInvalidType(InvalidType node); @@ -913,7 +913,7 @@ typedef DartTypeVisitor1AuxiliaryFunction = ); abstract class DartTypeVisitor1 { - const DartTypeVisitor1(); + const new(); R visitAuxiliaryType(AuxiliaryType node, A arg); R visitInvalidType(InvalidType node, A arg); @@ -989,7 +989,7 @@ mixin DartTypeVisitor1DefaultMixin implements DartTypeVisitor1 { /// Use [ComputeOnceConstantVisitor] or [VisitOnceConstantVisitor] to visit /// a constant node while ensuring each subnode is only visited once. abstract class ConstantVisitor { - const ConstantVisitor(); + const new(); R visitAuxiliaryConstant(AuxiliaryConstant node); R visitNullConstant(NullConstant node); @@ -1066,7 +1066,7 @@ mixin ConstantVisitorDefaultMixin implements ConstantVisitor { } abstract class ConstantVisitor1 { - const ConstantVisitor1(); + const new(); R visitAuxiliaryConstant(AuxiliaryConstant node, A arg); R visitNullConstant(NullConstant node, A arg); @@ -1366,7 +1366,7 @@ abstract class _ConstantCallback { class _ConstantCallbackVisitor implements ConstantVisitor { final _ConstantCallback _callback; - _ConstantCallbackVisitor(this._callback); + new(this._callback); @override R visitUnevaluatedConstant(UnevaluatedConstant node) => @@ -1499,7 +1499,7 @@ abstract class ComputeOnceConstantVisitor implements _ConstantCallback { late final _ConstantCallbackVisitor _visitor; Map cache = new LinkedHashMap.identity(); - ComputeOnceConstantVisitor() { + new() { _visitor = new _ConstantCallbackVisitor(this); } @@ -1530,7 +1530,7 @@ abstract class VisitOnceConstantVisitor implements _ConstantCallback { late final _ConstantCallbackVisitor _visitor; Set cache = new LinkedHashSet.identity(); - VisitOnceConstantVisitor() { + new() { _visitor = new _ConstantCallbackVisitor(this); } @@ -1546,7 +1546,7 @@ abstract class VisitOnceConstantVisitor implements _ConstantCallback { } abstract class MemberReferenceVisitor { - const MemberReferenceVisitor(); + const new(); R visitFieldReference(Field node); R visitConstructorReference(Constructor node); @@ -1568,7 +1568,7 @@ mixin MemberReferenceVisitorDefaultMixin } abstract class MemberReferenceVisitor1 { - const MemberReferenceVisitor1(); + const new(); R visitFieldReference(Field node, A arg); R visitConstructorReference(Constructor node, A arg); @@ -1598,7 +1598,7 @@ abstract class Visitor ConstantVisitor, MemberReferenceVisitor, ConstantReferenceVisitor { - const Visitor(); + const new(); // TODO(johnniwinther): Move these to [MemberReferenceVisitor]. R visitClassReference(Class node); @@ -1636,7 +1636,7 @@ abstract class VisitorDefault extends TreeVisitorDefault ConstantVisitorDefaultMixin, MemberReferenceVisitorDefaultMixin, ConstantReferenceVisitorDefaultMixin { - const VisitorDefault(); + const new(); @override R defaultTreeNode(TreeNode node) => defaultNode(node); @@ -1654,7 +1654,7 @@ abstract class Visitor1 extends TreeVisitor1 ConstantVisitor1, MemberReferenceVisitor1, ConstantReferenceVisitor1 { - const Visitor1(); + const new(); // TODO(johnniwinther): Move these to [MemberReferenceVisitor1]. R visitClassReference(Class node, A arg); @@ -1699,7 +1699,7 @@ abstract class Visitor1Default extends TreeVisitor1Default ConstantVisitor1DefaultMixin, MemberReferenceVisitor1DefaultMixin, ConstantReferenceVisitor1DefaultMixin { - const Visitor1Default(); + const new(); @override R defaultTreeNode(TreeNode node, A arg) => defaultNode(node, arg); @@ -1849,7 +1849,7 @@ mixin VisitorDefaultValueMixin implements VisitorDefault { /// Recursive visitor that doesn't return anything from its visit methods. class RecursiveVisitor extends VisitorDefault with VisitorVoidMixin { - const RecursiveVisitor(); + const new(); @override void defaultNode(Node node) { @@ -1861,7 +1861,7 @@ class RecursiveVisitor extends VisitorDefault with VisitorVoidMixin { /// visit methods. class RecursiveResultVisitor extends VisitorDefault with VisitorNullMixin { - const RecursiveResultVisitor(); + const new(); @override R? defaultNode(Node node) { @@ -1896,7 +1896,7 @@ class RecursiveResultVisitor extends VisitorDefault /// } /// class Transformer extends TreeVisitorDefault { - const Transformer(); + const new(); T transform(T node) { return node.accept(this) as T; @@ -2003,7 +2003,7 @@ class Transformer extends TreeVisitorDefault { /// } /// class RemovingTransformer extends TreeVisitor1Default { - const RemovingTransformer(); + const new(); /// Visits [node], returning the transformation result. /// @@ -2328,7 +2328,7 @@ class RemovingTransformer extends TreeVisitor1Default { } abstract class ExpressionVisitor1 { - const ExpressionVisitor1(); + const new(); R visitAuxiliaryExpression(AuxiliaryExpression node, A arg); R visitInvalidExpression(InvalidExpression node, A arg); @@ -2677,7 +2677,7 @@ mixin PatternVisitor1DefaultMixin implements PatternVisitor1 { } abstract class StatementVisitor1 { - const StatementVisitor1(); + const new(); R visitAuxiliaryStatement(AuxiliaryStatement node, A arg); R visitExpressionStatement(ExpressionStatement node, A arg); @@ -2778,7 +2778,7 @@ mixin StatementVisitor1DefaultMixin implements StatementVisitor1 { } abstract class VariableVisitor1 { - const VariableVisitor1(); + const new(); R visitLegacyVariable(LegacyVariable node, A arg); R visitPositionalParameter(PositionalParameter node, A arg); diff --git a/pkg/kernel/pubspec.yaml b/pkg/kernel/pubspec.yaml index 605c7017ca1..c1690b0d181 100644 --- a/pkg/kernel/pubspec.yaml +++ b/pkg/kernel/pubspec.yaml @@ -6,7 +6,7 @@ name: kernel publish_to: none environment: - sdk: '^3.12.0-0' + sdk: '^3.13.0-0' resolution: workspace diff --git a/pkg/kernel/test/binary_bench.dart b/pkg/kernel/test/binary_bench.dart index 2ac19861284..af5dd2bcd72 100644 --- a/pkg/kernel/test/binary_bench.dart +++ b/pkg/kernel/test/binary_bench.dart @@ -113,7 +113,7 @@ class BenchmarkResult { final double warmupUs; final List runsUs; - BenchmarkResult(this.name, this.coldRunUs, this.warmupUs, this.runsUs); + new(this.name, this.coldRunUs, this.warmupUs, this.runsUs); static T add(T x, T y) => x + y as T; diff --git a/pkg/kernel/test/check_equivalence_test.dart b/pkg/kernel/test/check_equivalence_test.dart index b19120eb7bc..29710604742 100644 --- a/pkg/kernel/test/check_equivalence_test.dart +++ b/pkg/kernel/test/check_equivalence_test.dart @@ -376,7 +376,7 @@ class Test { final bool? unorderedConstructors; final bool? unorderedAnnotations; - Test( + new( Node Function(bool) create, { this.inequivalence, this.unorderedLibraries, diff --git a/pkg/kernel/test/class_hierarchy_basic.dart b/pkg/kernel/test/class_hierarchy_basic.dart index d0a78672b8c..1b7d6d69761 100644 --- a/pkg/kernel/test/class_hierarchy_basic.dart +++ b/pkg/kernel/test/class_hierarchy_basic.dart @@ -28,8 +28,7 @@ class BasicClassHierarchy implements ClassHierarchy { final List classes = []; final Map classIndex = {}; - BasicClassHierarchy(Component component) - : knownLibraries = component.libraries.toSet() { + new(Component component) : knownLibraries = component.libraries.toSet() { for (var library in knownLibraries) { for (var classNode in library.classes) { buildSuperTypeSets(classNode); diff --git a/pkg/kernel/test/class_hierarchy_test.dart b/pkg/kernel/test/class_hierarchy_test.dart index 469aec65d84..5fc2ec932fb 100644 --- a/pkg/kernel/test/class_hierarchy_test.dart +++ b/pkg/kernel/test/class_hierarchy_test.dart @@ -86,7 +86,7 @@ class ClosedWorldClassHierarchyTest { ClassHierarchy? _hierarchy; - ClosedWorldClassHierarchyTest() { + new() { coreTypes = new CoreTypes(component); Uri uri = Uri.parse('org-dartlang:///test.dart'); library = new Library(uri, fileUri: uri, name: 'test'); diff --git a/pkg/kernel/test/clone_test.dart b/pkg/kernel/test/clone_test.dart index 803e66b200b..b53f49222e0 100644 --- a/pkg/kernel/test/clone_test.dart +++ b/pkg/kernel/test/clone_test.dart @@ -151,7 +151,7 @@ void testMemberCloning() { } class NoFileOffsetEquivalenceStrategy extends EquivalenceStrategy { - const NoFileOffsetEquivalenceStrategy(); + const new(); @override bool checkTreeNode_fileOffset( @@ -165,7 +165,7 @@ class NoFileOffsetEquivalenceStrategy extends EquivalenceStrategy { } class MemberEquivalenceStrategy extends EquivalenceStrategy { - const MemberEquivalenceStrategy(); + const new(); void assumeClonedReferences( EquivalenceVisitor visitor, diff --git a/pkg/kernel/test/equivalence_test.dart b/pkg/kernel/test/equivalence_test.dart index 913262df868..3ac813941b1 100644 --- a/pkg/kernel/test/equivalence_test.dart +++ b/pkg/kernel/test/equivalence_test.dart @@ -204,7 +204,7 @@ class Test { final String? inequivalence; final EquivalenceStrategy strategy; - Test( + new( this.a, this.b, { this.inequivalence, @@ -215,7 +215,7 @@ class Test { } class IgnoreIntLiteralValue extends EquivalenceStrategy { - const IgnoreIntLiteralValue(); + const new(); @override bool checkIntLiteral_value( diff --git a/pkg/kernel/test/flatten_test.dart b/pkg/kernel/test/flatten_test.dart index bf3b0ee3164..483f1252ef6 100644 --- a/pkg/kernel/test/flatten_test.dart +++ b/pkg/kernel/test/flatten_test.dart @@ -47,7 +47,7 @@ class Test { final String output; final String? typeParameters; - const Test(this.input, this.output, [this.typeParameters]); + const new(this.input, this.output, [this.typeParameters]); } void main() { diff --git a/pkg/kernel/test/graph_test.dart b/pkg/kernel/test/graph_test.dart index 67029b938a8..f5229996d32 100644 --- a/pkg/kernel/test/graph_test.dart +++ b/pkg/kernel/test/graph_test.dart @@ -18,7 +18,7 @@ const String F = 'F'; class TestGraph implements Graph { final Map> graph; - TestGraph(this.graph); + new(this.graph); @override Iterable get vertices => graph.keys; diff --git a/pkg/kernel/test/reference_name_test.dart b/pkg/kernel/test/reference_name_test.dart index 4a85c2f5d8a..8bf5adb747b 100644 --- a/pkg/kernel/test/reference_name_test.dart +++ b/pkg/kernel/test/reference_name_test.dart @@ -438,5 +438,5 @@ class ReferenceNameObject { final ReferenceName referenceName; final Object object; - ReferenceNameObject(this.referenceName, this.object); + new(this.referenceName, this.object); } diff --git a/pkg/kernel/test/type_hashcode_test.dart b/pkg/kernel/test/type_hashcode_test.dart index bd534f3b104..b3c2af6a0c7 100644 --- a/pkg/kernel/test/type_hashcode_test.dart +++ b/pkg/kernel/test/type_hashcode_test.dart @@ -78,14 +78,11 @@ class TestCase { Map? expectedSubstitution; // Null if unification should fail. - TestCase.success( - this.type1, - this.type2, - Map expectedSubstitution, - ) : this.expectedSubstitution = expectedSubstitution, + new success(this.type1, this.type2, Map expectedSubstitution) + : this.expectedSubstitution = expectedSubstitution, this.quantifiedVariables = expectedSubstitution.keys; - TestCase.fail(this.type1, this.type2, this.quantifiedVariables); + new fail(this.type1, this.type2, this.quantifiedVariables); bool get shouldSucceed => expectedSubstitution != null; diff --git a/pkg/kernel/test/type_parser.dart b/pkg/kernel/test/type_parser.dart index 72305f0be20..54d62cf5ffe 100644 --- a/pkg/kernel/test/type_parser.dart +++ b/pkg/kernel/test/type_parser.dart @@ -43,7 +43,7 @@ class DartTypeParser { final Map localTypeParameters = {}; - DartTypeParser(this.string, this.environment); + new(this.string, this.environment); /* TreeNode? | StructuralParameter? */ Object? lookupType(String name) { @@ -386,7 +386,7 @@ class LazyTypeEnvironment { late final Library dummyLibrary; final Component component = new Component(); - LazyTypeEnvironment() { + new() { Uri uri = Uri.parse('file://dummy.dart'); dummyLibrary = new Library(uri, fileUri: uri); component.libraries.add(dummyLibrary..parent = component); diff --git a/pkg/kernel/test/type_substitute_bounds_test.dart b/pkg/kernel/test/type_substitute_bounds_test.dart index 37312439d01..ff356b71f79 100644 --- a/pkg/kernel/test/type_substitute_bounds_test.dart +++ b/pkg/kernel/test/type_substitute_bounds_test.dart @@ -43,7 +43,7 @@ class TestCase { final Map bounds; final String expected; - TestCase(this.type, this.bounds, this.expected); + new(this.type, this.bounds, this.expected); @override String toString() { @@ -60,7 +60,7 @@ class TestCase { class TypeBound { final String lower, upper; - TypeBound(this.lower, this.upper); + new(this.lower, this.upper); } TypeBound bound(String lower, String upper) => new TypeBound(lower, upper); diff --git a/pkg/kernel/test/verify_test.dart b/pkg/kernel/test/verify_test.dart index 546efed3d49..3494ace6dfb 100644 --- a/pkg/kernel/test/verify_test.dart +++ b/pkg/kernel/test/verify_test.dart @@ -940,7 +940,7 @@ class TestHarness { return new TypeParameter(name, objectRawType, const DynamicType()); } - TestHarness() { + new() { setupComponent(); }