diff --git a/pkg/compiler/lib/src/common/codegen.dart b/pkg/compiler/lib/src/common/codegen.dart index 743b70fd099..7c176592652 100644 --- a/pkg/compiler/lib/src/common/codegen.dart +++ b/pkg/compiler/lib/src/common/codegen.dart @@ -102,26 +102,21 @@ class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact { factory _CodegenImpact.readFromDataSource(DataSourceReader source) { source.begin(tag); MemberEntity member = source.readMember(); - final dynamicUses = - source - .readListOrNull(() => DynamicUse.readFromDataSource(source)) - ?.toSet(); - final staticUses = - source - .readListOrNull(() => StaticUse.readFromDataSource(source)) - ?.toSet(); - final typeUses = - source - .readListOrNull(() => TypeUse.readFromDataSource(source)) - ?.toSet(); - final constantUses = - source - .readListOrNull(() => ConstantUse.readFromDataSource(source)) - ?.toSet(); - final typeVariableBoundsSubtypeChecks = - source.readListOrNull(() { - return (source.readDartType(), source.readDartType()); - })?.toSet(); + final dynamicUses = source + .readListOrNull(() => DynamicUse.readFromDataSource(source)) + ?.toSet(); + final staticUses = source + .readListOrNull(() => StaticUse.readFromDataSource(source)) + ?.toSet(); + final typeUses = source + .readListOrNull(() => TypeUse.readFromDataSource(source)) + ?.toSet(); + final constantUses = source + .readListOrNull(() => ConstantUse.readFromDataSource(source)) + ?.toSet(); + final typeVariableBoundsSubtypeChecks = source.readListOrNull(() { + return (source.readDartType(), source.readDartType()); + })?.toSet(); final constSymbols = source.readStringsOrNull()?.toSet(); final specializedGetInterceptors = source.readListOrNull(() { return source.readClasses().toSet(); @@ -129,20 +124,16 @@ class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact { bool usesInterceptor = source.readBool(); final asyncMarkersValue = source.readInt(); final asyncMarkers = EnumSet.fromRawBits(asyncMarkersValue); - final genericInstantiations = - source - .readListOrNull( - () => GenericInstantiation.readFromDataSource(source), - ) - ?.toSet(); + final genericInstantiations = source + .readListOrNull(() => GenericInstantiation.readFromDataSource(source)) + ?.toSet(); final nativeBehaviors = source.readListOrNull( () => NativeBehavior.readFromDataSource(source), ); final nativeMethods = source.readMembersOrNull()?.toSet(); - final oneShotInterceptors = - source - .readListOrNull(() => Selector.readFromDataSource(source)) - ?.toSet(); + final oneShotInterceptors = source + .readListOrNull(() => Selector.readFromDataSource(source)) + ?.toSet(); source.end(tag); return _CodegenImpact.internal( member, @@ -455,8 +446,8 @@ class CodegenResult { source.begin(tag); js.Fun? code = source.readJsNodeOrNull() as js.Fun?; CodegenImpact impact = CodegenImpact.readFromDataSource(source); - final deferredExpressionData = js - .DeferredExpressionRegistry.readDataFromDataSource(source); + final deferredExpressionData = + js.DeferredExpressionRegistry.readDataFromDataSource(source); source.end(tag); if (code != null) { code = code.withAnnotation(deferredExpressionData) as js.Fun; diff --git a/pkg/compiler/lib/src/common/elements.dart b/pkg/compiler/lib/src/common/elements.dart index 1d66b17992d..8d3bedcd1f3 100644 --- a/pkg/compiler/lib/src/common/elements.dart +++ b/pkg/compiler/lib/src/common/elements.dart @@ -100,8 +100,10 @@ abstract class CommonElements { late final ClassEntity streamClass = _findClass(asyncLibrary, 'Stream'); /// The dart:core library. - late final LibraryEntity coreLibrary = - _env.lookupLibrary(Uris.dartCore, required: true)!; + late final LibraryEntity coreLibrary = _env.lookupLibrary( + Uris.dartCore, + required: true, + )!; /// The dart:async library. late final LibraryEntity? asyncLibrary = _env.lookupLibrary(Uris.dartAsync); @@ -118,12 +120,16 @@ abstract class CommonElements { ); /// The dart:typed_data library. - late final LibraryEntity typedDataLibrary = - _env.lookupLibrary(Uris.dartNativeTypedData, required: true)!; + late final LibraryEntity typedDataLibrary = _env.lookupLibrary( + Uris.dartNativeTypedData, + required: true, + )!; /// The dart:_js_shared_embedded_names library. - late final LibraryEntity sharedEmbeddedNamesLibrary = - _env.lookupLibrary(Uris.dartJSSharedEmbeddedNames, required: true)!; + late final LibraryEntity sharedEmbeddedNamesLibrary = _env.lookupLibrary( + Uris.dartJSSharedEmbeddedNames, + required: true, + )!; /// The dart:_js_helper library. late final LibraryEntity? jsHelperLibrary = _env.lookupLibrary( @@ -146,12 +152,16 @@ abstract class CommonElements { ); /// The dart:_rti library. - late final LibraryEntity rtiLibrary = - _env.lookupLibrary(Uris.dartRti, required: true)!; + late final LibraryEntity rtiLibrary = _env.lookupLibrary( + Uris.dartRti, + required: true, + )!; /// The dart:_internal library. - late final LibraryEntity internalLibrary = - _env.lookupLibrary(Uris.dartInternal, required: true)!; + late final LibraryEntity internalLibrary = _env.lookupLibrary( + Uris.dartInternal, + required: true, + )!; /// The dart:js_util library. late final LibraryEntity? dartJsUtilLibrary = _env.lookupLibrary( @@ -185,8 +195,10 @@ abstract class CommonElements { // TODO(johnniwinther): Kernel does not include redirecting factories // so this cannot be found in kernel. Find a consistent way to handle // this and similar cases. - return _symbolConstructorTarget ??= - _env.lookupConstructor(symbolImplementationClass, '')!; + return _symbolConstructorTarget ??= _env.lookupConstructor( + symbolImplementationClass, + '', + )!; } void _ensureSymbolConstructorDependencies() { @@ -227,8 +239,10 @@ abstract class CommonElements { } /// The function `identical` in dart:core. - late final FunctionEntity identicalFunction = - _findLibraryMember(coreLibrary, 'identical')!; + late final FunctionEntity identicalFunction = _findLibraryMember( + coreLibrary, + 'identical', + )!; /// Whether [element] is the `Function.apply` method. /// @@ -420,8 +434,9 @@ abstract class CommonElements { bool onlyStringKeys = false, }) { // TODO(51534): Use CONST_CANONICAL_TYPE(T_i) for arguments. - ClassEntity classElement = - onlyStringKeys ? constantStringMapClass : generalConstantMapClass; + ClassEntity classElement = onlyStringKeys + ? constantStringMapClass + : generalConstantMapClass; return _env.createInterfaceType(classElement, sourceType.typeArguments); } @@ -430,25 +445,25 @@ abstract class CommonElements { bool onlyStringKeys = false, }) { // TODO(51534): Use CONST_CANONICAL_TYPE(T_i) for arguments. - ClassEntity classElement = - onlyStringKeys ? constantStringSetClass : generalConstantSetClass; + ClassEntity classElement = onlyStringKeys + ? constantStringSetClass + : generalConstantSetClass; return _env.createInterfaceType(classElement, sourceType.typeArguments); } /// Returns the field that holds the internal name in the implementation class /// for `Symbol`. - FieldEntity get symbolField => - _symbolImplementationField ??= - _env.lookupLocalClassMember( - symbolImplementationClass, - PrivateName( - '_name', - symbolImplementationClass.library.canonicalUri, - ), - required: true, - ) - as FieldEntity; + FieldEntity get symbolField => _symbolImplementationField ??= + _env.lookupLocalClassMember( + symbolImplementationClass, + PrivateName( + '_name', + symbolImplementationClass.library.canonicalUri, + ), + required: true, + ) + as FieldEntity; InterfaceType get symbolImplementationType => _env.getRawType(symbolImplementationClass); @@ -462,10 +477,12 @@ abstract class CommonElements { return _mapLiteralClass!; } - late final ConstructorEntity mapLiteralConstructor = - _env.lookupConstructor(mapLiteralClass, '_literal')!; - late final ConstructorEntity mapLiteralConstructorEmpty = - _env.lookupConstructor(mapLiteralClass, '_empty')!; + late final ConstructorEntity mapLiteralConstructor = _env.lookupConstructor( + mapLiteralClass, + '_literal', + )!; + late final ConstructorEntity mapLiteralConstructorEmpty = _env + .lookupConstructor(mapLiteralClass, '_empty')!; late final FunctionEntity mapLiteralUntypedMaker = _env.lookupLocalClassMember( mapLiteralClass, @@ -484,10 +501,12 @@ abstract class CommonElements { 'LinkedHashSet', ); - late final ConstructorEntity setLiteralConstructor = - _env.lookupConstructor(setLiteralClass, '_literal')!; - late final ConstructorEntity setLiteralConstructorEmpty = - _env.lookupConstructor(setLiteralClass, '_empty')!; + late final ConstructorEntity setLiteralConstructor = _env.lookupConstructor( + setLiteralClass, + '_literal', + )!; + late final ConstructorEntity setLiteralConstructorEmpty = _env + .lookupConstructor(setLiteralClass, '_empty')!; late final FunctionEntity setLiteralUntypedMaker = _env.lookupLocalClassMember( setLiteralClass, @@ -716,8 +735,10 @@ abstract class CommonElements { late final FunctionEntity getNativeInterceptorMethod = _findInterceptorsFunction('getNativeInterceptor'); - late final ConstructorEntity jsArrayTypedConstructor = - _env.lookupConstructor(jsArrayClass, 'typed')!; + late final ConstructorEntity jsArrayTypedConstructor = _env.lookupConstructor( + jsArrayClass, + 'typed', + )!; // From dart:_js_helper // TODO(johnniwinther): Avoid the need for this (from [CheckedModeHelper]). diff --git a/pkg/compiler/lib/src/common/tasks.dart b/pkg/compiler/lib/src/common/tasks.dart index 75deb011336..e10abbc21c1 100644 --- a/pkg/compiler/lib/src/common/tasks.dart +++ b/pkg/compiler/lib/src/common/tasks.dart @@ -109,12 +109,11 @@ abstract class CompilerTask { return runZoned( action, zoneValues: _zoneValues ??= {_measurer: this}, - zoneSpecification: - _zoneSpecification ??= ZoneSpecification( - run: _run, - runUnary: _runUnary, - runBinary: _runBinary, - ), + zoneSpecification: _zoneSpecification ??= ZoneSpecification( + run: _run, + runUnary: _runUnary, + runBinary: _runBinary, + ), ); } diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart index c81e02692e8..83b4f0e12d4 100644 --- a/pkg/compiler/lib/src/compiler.dart +++ b/pkg/compiler/lib/src/compiler.dart @@ -159,10 +159,9 @@ class Compiler { options.validate(); environment = Environment(options.environment); - abstractValueStrategy = - options.useTrivialAbstractValueDomain - ? const TrivialAbstractValueStrategy() - : const TypeMaskStrategy(); + abstractValueStrategy = options.useTrivialAbstractValueDomain + ? const TrivialAbstractValueStrategy() + : const TypeMaskStrategy(); if (options.debugGlobalInference) { abstractValueStrategy = ComputableAbstractValueStrategy( abstractValueStrategy, @@ -267,8 +266,10 @@ class Compiler { return '${library.importUri}(${library.fileUri})'; } - var unusedLibraries = - component.libraries.where(isUnused).map(libraryString).toList(); + var unusedLibraries = component.libraries + .where(isUnused) + .map(libraryString) + .toList(); unusedLibraries.sort(); var jsonLibraries = jsonEncode(unusedLibraries); outputProvider.createOutputSink( @@ -318,10 +319,9 @@ class Compiler { if (options.readProgramSplit != null) { var constraintUri = options.readProgramSplit; var constraintParser = psc.Parser(); - var programSplitJson = - await CompilerFileSystem( - provider, - ).entityForUri(constraintUri!).readAsString(); + var programSplitJson = await CompilerFileSystem( + provider, + ).entityForUri(constraintUri!).readAsString(); programSplitConstraintsData = constraintParser.read(programSplitJson); } @@ -353,9 +353,9 @@ class Compiler { List libraries, ) { frontendStrategy.registerLoadedLibraries(component, libraries); - ResolutionEnqueuer resolutionEnqueuer = frontendStrategy - .createResolutionEnqueuer(enqueueTask, this) - ..onEmptyForTesting = onResolutionQueueEmptyForTesting; + ResolutionEnqueuer resolutionEnqueuer = + frontendStrategy.createResolutionEnqueuer(enqueueTask, this) + ..onEmptyForTesting = onResolutionQueueEmptyForTesting; if (retainDataForTesting) { resolutionEnqueuerForTesting = resolutionEnqueuer; resolutionWorldBuilderForTesting = resolutionEnqueuer.worldBuilder; @@ -455,8 +455,8 @@ class Compiler { } return output.withNewComponent(component); } else { - ir.Component component = - await serializationTask.deserializeComponentAndUpdateOptions(); + ir.Component component = await serializationTask + .deserializeComponentAndUpdateOptions(); if (retainDataForTesting) { componentForTesting = component; } @@ -952,8 +952,8 @@ class Compiler { // so that tests can determine the cause of the message. final messageText = diagnosticMessage is DiagnosticCfeMessage && options.testMode - ? diagnosticMessage.messageCode - : '$message'; + ? diagnosticMessage.messageCode + : '$message'; if (span.isUnknown) { callUserHandler(message, null, null, null, messageText, kind); } else { diff --git a/pkg/compiler/lib/src/constants/constant_system.dart b/pkg/compiler/lib/src/constants/constant_system.dart index b97e1907c14..a11747f223d 100644 --- a/pkg/compiler/lib/src/constants/constant_system.dart +++ b/pkg/compiler/lib/src/constants/constant_system.dart @@ -425,8 +425,9 @@ class ShiftRightOperation extends BinaryBitOperation { ConstantValue adjustedLeft = left; if (left is IntConstantValue) { BigInt value = left.intValue; - BigInt truncated = - value.isNegative ? value.toSigned(32) : value.toUnsigned(32); + BigInt truncated = value.isNegative + ? value.toSigned(32) + : value.toUnsigned(32); if (value != truncated) { adjustedLeft = createInt(truncated); } diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart index 780d4020ec5..d31425eddaa 100644 --- a/pkg/compiler/lib/src/dart2js.dart +++ b/pkg/compiler/lib/src/dart2js.dart @@ -715,10 +715,9 @@ Future compile( } // TODO(johnniwinther): Measure time for reading files. - SourceFileByteReader byteReader = - compilerOptions.memoryMappedFiles - ? const MemoryMapSourceFileByteReader() - : const MemoryCopySourceFileByteReader(); + SourceFileByteReader byteReader = compilerOptions.memoryMappedFiles + ? const MemoryMapSourceFileByteReader() + : const MemoryCopySourceFileByteReader(); SourceFileProvider inputProvider; if (bazelPaths != null) { @@ -990,8 +989,9 @@ void writeString(Uri uri, String text) { if (!uri.isScheme('file')) { _fail('Unhandled scheme ${uri.scheme}.'); } - var file = (File(uri.toFilePath()) - ..createSync(recursive: true)).openSync(mode: FileMode.write); + var file = (File( + uri.toFilePath(), + )..createSync(recursive: true)).openSync(mode: FileMode.write); file.writeStringSync(text); file.closeSync(); } @@ -1052,7 +1052,8 @@ Usage: dart compile js [arguments] -O2 Safe production-oriented optimizations (like minification). -O3 Potentially unsafe optimizations (see -h -v for details). -O4 More aggressive unsafe optimizations (see -h -v for details). -'''.trim(), +''' + .trim(), ); } @@ -1244,7 +1245,8 @@ be removed in a future version: --no-frequency-based-minification Experimental. Disable the new frequency based minifying namer and use the old namer instead. -'''.trim(), +''' + .trim(), ); } diff --git a/pkg/compiler/lib/src/deferred_load/deferred_load.dart b/pkg/compiler/lib/src/deferred_load/deferred_load.dart index 10b20008fc5..4f9730f80f0 100644 --- a/pkg/compiler/lib/src/deferred_load/deferred_load.dart +++ b/pkg/compiler/lib/src/deferred_load/deferred_load.dart @@ -644,10 +644,9 @@ class DeferredLoadTask extends CompilerTask { unitText.write('
'); } else { unitText.write(' imports:'); - var imports = - outputUnit.imports - .map((i) => '${i.enclosingLibraryUri.resolveUri(i.uri)}') - .toList(); + var imports = outputUnit.imports + .map((i) => '${i.enclosingLibraryUri.resolveUri(i.uri)}') + .toList(); for (var i in imports..sort()) { unitText.write('\n $i:'); } diff --git a/pkg/compiler/lib/src/deferred_load/program_split_constraints/builder.dart b/pkg/compiler/lib/src/deferred_load/program_split_constraints/builder.dart index dceb7994b38..d59526986a9 100644 --- a/pkg/compiler/lib/src/deferred_load/program_split_constraints/builder.dart +++ b/pkg/compiler/lib/src/deferred_load/program_split_constraints/builder.dart @@ -83,8 +83,8 @@ class Builder { for (var import in imports) { var libraryUri = import.enclosingLibraryUri; var prefix = import.name; - Map uriNodes = - importsByUriAndPrefix[libraryUri] ??= {}; + Map uriNodes = importsByUriAndPrefix[libraryUri] ??= + {}; uriNodes[prefix!] = import; } @@ -181,8 +181,9 @@ class Builder { } } else { assert(constraint.combinerType == CombinerType.or); - var setTransition = - setTransitions[constraint] ??= SetTransition(constraint.imports); + var setTransition = setTransitions[constraint] ??= SetTransition( + constraint.imports, + ); setTransition.transitions.addAll(transitiveChildren); } diff --git a/pkg/compiler/lib/src/diagnostics/diagnostic_listener.dart b/pkg/compiler/lib/src/diagnostics/diagnostic_listener.dart index bfe519f5c8a..d9ea360ac0e 100644 --- a/pkg/compiler/lib/src/diagnostics/diagnostic_listener.dart +++ b/pkg/compiler/lib/src/diagnostics/diagnostic_listener.dart @@ -218,8 +218,9 @@ class DiagnosticReporter { } void _reportAssertionFailure(SpannableAssertionFailure ex) { - String message = - (ex.message != null) ? tryToString(ex.message!) : tryToString(ex); + String message = (ex.message != null) + ? tryToString(ex.message!) + : tryToString(ex); _reportDiagnosticInternal( createMessage(ex.node, MessageKind.generic, {'text': message}), const [], diff --git a/pkg/compiler/lib/src/dump_info.dart b/pkg/compiler/lib/src/dump_info.dart index b03d43fdf14..5dca3d0af26 100644 --- a/pkg/compiler/lib/src/dump_info.dart +++ b/pkg/compiler/lib/src/dump_info.dart @@ -672,18 +672,18 @@ class ElementInfoCollector { } if (function is ConstructorEntity) { - name = - name == "" - ? function.enclosingClass.name - : "${function.enclosingClass.name}.${function.name}"; + name = name == "" + ? function.enclosingClass.name + : "${function.enclosingClass.name}.${function.name}"; kind = FunctionInfo.CONSTRUCTOR_FUNCTION_KIND; } FunctionModifiers modifiers = FunctionModifiers( isStatic: function.isStatic, isConst: function.isConst, - isFactory: - function is ConstructorEntity ? function.isFactoryConstructor : false, + isFactory: function is ConstructorEntity + ? function.isFactoryConstructor + : false, isExternal: function.isExternal, ); List code = dumpInfoTask.codeOf(function); @@ -777,10 +777,9 @@ class ElementInfoCollector { return state.outputToInfo.putIfAbsent(outputUnit, () { // Dump-info currently only works with the full emitter. If another // emitter is used it will fail here. - final filename = - outputUnit.isMainOutput - ? (options.outputUri?.pathSegments.last ?? 'out') - : deferredPartFileName(options, outputUnit.name); + final filename = outputUnit.isMainOutput + ? (options.outputUri?.pathSegments.last ?? 'out') + : deferredPartFileName(options, outputUnit.name); OutputUnitInfo info = OutputUnitInfo( filename, outputUnit.name, @@ -946,8 +945,9 @@ class KernelInfoCollector { if (superclass == coreTypes.objectClass) { continue; } - final superclassLibrary = - environment.lookupLibrary(superclass.enclosingLibrary.importUri)!; + final superclassLibrary = environment.lookupLibrary( + superclass.enclosingLibrary.importUri, + )!; final superclassEntity = environment.lookupClass( superclassLibrary, superclass.name, @@ -1064,10 +1064,9 @@ class KernelInfoCollector { ); // TODO(markzipan): Determine if it's safe to default to nonNullable here. - final nullability = - parent is ir.Member - ? parent.enclosingLibrary.nonNullable - : ir.Nullability.nonNullable; + final nullability = parent is ir.Member + ? parent.enclosingLibrary.nonNullable + : ir.Nullability.nonNullable; final functionType = function.computeFunctionType(nullability); FunctionInfo info = FunctionInfo.fromKernel( @@ -1279,14 +1278,13 @@ class DumpInfoAnnotator { return null; } - final kFieldInfos = - kernelInfo.state.info.fields - .where( - (f) => - f.name == field.name && - fullyResolvedNameForInfo(f.parent) == parentName, - ) - .toList(); + final kFieldInfos = kernelInfo.state.info.fields + .where( + (f) => + f.name == field.name && + fullyResolvedNameForInfo(f.parent) == parentName, + ) + .toList(); assert( kFieldInfos.length == 1, 'Ambiguous field resolution. ' @@ -1349,14 +1347,13 @@ class DumpInfoAnnotator { // TODO(markzipan): [parentName] is used for disambiguation, but this might // not always be valid. Check and validate later. ClassInfo? visitClass(ClassEntity clazz, String parentName) { - final kClassInfos = - kernelInfo.state.info.classes - .where( - (i) => - i.name == clazz.name && - fullyResolvedNameForInfo(i.parent) == parentName, - ) - .toList(); + final kClassInfos = kernelInfo.state.info.classes + .where( + (i) => + i.name == clazz.name && + fullyResolvedNameForInfo(i.parent) == parentName, + ) + .toList(); assert( kClassInfos.length == 1, 'Ambiguous class resolution. ' @@ -1432,10 +1429,9 @@ class DumpInfoAnnotator { ClosureInfo? visitClosureClass(ClassEntity element) { final disambiguatedElementName = entityDisambiguator.name(element); - final kClosureInfos = - kernelInfo.state.info.closures - .where((info) => info.name == disambiguatedElementName) - .toList(); + final kClosureInfos = kernelInfo.state.info.closures + .where((info) => info.name == disambiguatedElementName) + .toList(); assert( kClosureInfos.length == 1, 'Ambiguous closure resolution. ' @@ -1475,27 +1471,25 @@ class DumpInfoAnnotator { var compareName = function.name; if (function is ConstructorEntity) { - compareName = - compareName == "" - ? function.enclosingClass.name - : "${function.enclosingClass.name}.${function.name}"; + compareName = compareName == "" + ? function.enclosingClass.name + : "${function.enclosingClass.name}.${function.name}"; } // Multiple kernel members can sometimes map to a single JElement. // [isSetter] and [isGetter] are required for disambiguating these cases. - final kFunctionInfos = - kernelInfo.state.info.functions - .where( - (i) => - i.name == compareName && - (isClosure - ? i.parent!.name - : fullyResolvedNameForInfo(i.parent)) == - parentName && - !(function.isGetter ^ i.modifiers.isGetter) && - !(function.isSetter ^ i.modifiers.isSetter), - ) - .toList(); + final kFunctionInfos = kernelInfo.state.info.functions + .where( + (i) => + i.name == compareName && + (isClosure + ? i.parent!.name + : fullyResolvedNameForInfo(i.parent)) == + parentName && + !(function.isGetter ^ i.modifiers.isGetter) && + !(function.isSetter ^ i.modifiers.isSetter), + ) + .toList(); assert( kFunctionInfos.length <= 1, 'Ambiguous function resolution. ' @@ -1570,10 +1564,9 @@ class DumpInfoAnnotator { return kernelInfo.state.outputToInfo.putIfAbsent(outputUnit, () { // Dump-info currently only works with the full emitter. If another // emitter is used it will fail here. - final filename = - outputUnit.isMainOutput - ? (options.outputUri?.pathSegments.last ?? 'out') - : deferredPartFileName(options, outputUnit.name); + final filename = outputUnit.isMainOutput + ? (options.outputUri?.pathSegments.last ?? 'out') + : deferredPartFileName(options, outputUnit.name); OutputUnitInfo info = OutputUnitInfo( filename, outputUnit.name, @@ -1843,8 +1836,8 @@ class DumpInfoTask extends CompilerTask implements InfoReporter { DumpInfoStateData result = infoCollector.state; // Recursively build links to function uses - final functionEntities = - infoCollector.state.entityToInfo.keys.whereType(); + final functionEntities = infoCollector.state.entityToInfo.keys + .whereType(); for (final entity in functionEntities) { final info = infoCollector.state.entityToInfo[entity] as FunctionInfo; Iterable uses = getRetaining(entity, closedWorld); @@ -1861,8 +1854,8 @@ class DumpInfoTask extends CompilerTask implements InfoReporter { } // Recursively build links to field uses - final fieldEntity = - infoCollector.state.entityToInfo.keys.whereType(); + final fieldEntity = infoCollector.state.entityToInfo.keys + .whereType(); for (final entity in fieldEntity) { final info = infoCollector.state.entityToInfo[entity] as FieldInfo; Iterable uses = getRetaining(entity, closedWorld); @@ -1924,8 +1917,8 @@ class DumpInfoTask extends CompilerTask implements InfoReporter { DumpInfoStateData result = infoCollector.state; // Recursively build links to function uses - final functionEntities = - infoCollector.state.entityToInfo.keys.whereType(); + final functionEntities = infoCollector.state.entityToInfo.keys + .whereType(); for (final entity in functionEntities) { final info = infoCollector.state.entityToInfo[entity] as FunctionInfo; Iterable uses = getRetaining(entity, closedWorld); @@ -1943,8 +1936,8 @@ class DumpInfoTask extends CompilerTask implements InfoReporter { } // Recursively build links to field uses - final fieldEntity = - infoCollector.state.entityToInfo.keys.whereType(); + final fieldEntity = infoCollector.state.entityToInfo.keys + .whereType(); for (final entity in fieldEntity) { final info = infoCollector.state.entityToInfo[entity] as FieldInfo; Iterable uses = getRetaining(entity, closedWorld); diff --git a/pkg/compiler/lib/src/elements/types.dart b/pkg/compiler/lib/src/elements/types.dart index 4bfe1a56be2..d25331777b6 100644 --- a/pkg/compiler/lib/src/elements/types.dart +++ b/pkg/compiler/lib/src/elements/types.dart @@ -1826,18 +1826,20 @@ abstract class DartTypes { namedParameterTypes, typeVariables, ); - List normalizableVariables = - typeVariables - .where((FunctionTypeVariable t) => t.bound is NeverType) - .toList(); + List normalizableVariables = typeVariables + .where((FunctionTypeVariable t) => t.bound is NeverType) + .toList(); return normalizableVariables.isEmpty ? type : subst( - List.filled(normalizableVariables.length, neverType()), - normalizableVariables, - type, - ) - as FunctionType; + List.filled( + normalizableVariables.length, + neverType(), + ), + normalizableVariables, + type, + ) + as FunctionType; } DartType futureOrType(DartType typeArgument) { @@ -1889,10 +1891,12 @@ abstract class DartTypes { subst(arguments, t.typeVariables, type); DartType returnType = substType(t.returnType); List parameterTypes = t.parameterTypes.map(substType).toList(); - List optionalParameterTypes = - t.optionalParameterTypes.map(substType).toList(); - List namedParameterTypes = - t.namedParameterTypes.map(substType).toList(); + List optionalParameterTypes = t.optionalParameterTypes + .map(substType) + .toList(); + List namedParameterTypes = t.namedParameterTypes + .map(substType) + .toList(); return functionType( returnType, parameterTypes, @@ -2175,8 +2179,9 @@ abstract class DartTypes { // Interface Compositionality + Super-Interface: if (s is InterfaceType) { if (t is InterfaceType) { - InterfaceType? instance = - s.element == t.element ? s : asInstanceOf(s, t.element); + InterfaceType? instance = s.element == t.element + ? s + : asInstanceOf(s, t.element); if (instance == null) return false; List sArgs = instance.typeArguments; List tArgs = t.typeArguments; diff --git a/pkg/compiler/lib/src/inferrer/builder.dart b/pkg/compiler/lib/src/inferrer/builder.dart index 0d6219c9ec5..43142a99a3a 100644 --- a/pkg/compiler/lib/src/inferrer/builder.dart +++ b/pkg/compiler/lib/src/inferrer/builder.dart @@ -143,17 +143,15 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault _memberData = _inferrer.dataOfMember(_analyzedMember), // TODO(johnniwinther): Should side effects also be tracked for field // initializers? - _sideEffectsBuilder = - _analyzedMember is FunctionEntity - ? _inferrer.inferredDataBuilder.getSideEffectsBuilder( - _analyzedMember, - ) - : SideEffectsBuilder.free(_analyzedMember), + _sideEffectsBuilder = _analyzedMember is FunctionEntity + ? _inferrer.inferredDataBuilder.getSideEffectsBuilder( + _analyzedMember, + ) + : SideEffectsBuilder.free(_analyzedMember), _inGenerativeConstructor = _analyzedNode is ir.Constructor, - _capturedAndBoxed = - capturedAndBoxed != null - ? Map.from(capturedAndBoxed) - : {}, + _capturedAndBoxed = capturedAndBoxed != null + ? Map.from(capturedAndBoxed) + : {}, _stateInternal = previousState ?? LocalState.initial( @@ -458,11 +456,10 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault case ir.AsyncMarker.Sync: if (_returnType == null) { // No return in the body. - _returnType = - _state.seenReturnOrThrow - ? _types - .nonNullEmpty() // Body always throws. - : _types.nullType; + _returnType = _state.seenReturnOrThrow + ? _types + .nonNullEmpty() // Body always throws. + : _types.nullType; } else if (!_state.seenReturnOrThrow) { // We haven'TypeInformation seen returns on all branches. So the // method may also return null. @@ -727,18 +724,17 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault PhiElementTypeInformation? elementType; int length = 0; for (TypeInformation type in elementTypes) { - elementType = - elementType == null - ? _types.allocatePhi(null, null, type, isTry: false) - : _types.addPhiInput(null, elementType, type); + elementType = elementType == null + ? _types.allocatePhi(null, null, type, isTry: false) + : _types.addPhiInput(null, elementType, type); length++; } - final simplifiedElementType = - elementType == null - ? _types.nonNullEmpty() - : _types.simplifyPhi(null, null, elementType); - TypeInformation containerType = - isConst ? _types.constListType : _types.growableListType; + final simplifiedElementType = elementType == null + ? _types.nonNullEmpty() + : _types.simplifyPhi(null, null, elementType); + TypeInformation containerType = isConst + ? _types.constListType + : _types.growableListType; return _types.allocateList( containerType, node, @@ -766,17 +762,16 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault return _inferrer.concreteTypes.putIfAbsent(node, () { PhiElementTypeInformation? elementType; for (TypeInformation type in elementTypes) { - elementType = - elementType == null - ? _types.allocatePhi(null, null, type, isTry: false) - : _types.addPhiInput(null, elementType, type); + elementType = elementType == null + ? _types.allocatePhi(null, null, type, isTry: false) + : _types.addPhiInput(null, elementType, type); } - final simplifiedElementType = - elementType == null - ? _types.nonNullEmpty() - : _types.simplifyPhi(null, null, elementType); - TypeInformation containerType = - isConst ? _types.constSetType : _types.setType; + final simplifiedElementType = elementType == null + ? _types.nonNullEmpty() + : _types.simplifyPhi(null, null, elementType); + TypeInformation containerType = isConst + ? _types.constSetType + : _types.setType; return _types.allocateSet( containerType, node, @@ -1268,10 +1263,9 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault ir.VariableDeclaration? variable, ) { if (_types.selectorNeedsUpdate(receiverType, mask)) { - mask = - receiverType == _types.dynamicType - ? null - : _types.newTypedSelector(receiverType, mask); + mask = receiverType == _types.dynamicType + ? null + : _types.newTypedSelector(receiverType, mask); _inferrer.updateSelectorInMember( _analyzedMember, callType, @@ -1780,11 +1774,10 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault if (_isConstructorOfTypedArraySubclass(constructor)) { // We have something like `Uint32List(len)`. final length = _findLength(arguments); - final member = - _elementMap.elementEnvironment.lookupClassMember( - constructor.enclosingClass, - Names.indexName, - )!; + final member = _elementMap.elementEnvironment.lookupClassMember( + constructor.enclosingClass, + Names.indexName, + )!; TypeInformation elementType = _inferrer.returnTypeOfMember(member); return _inferrer.concreteTypes.putIfAbsent( node, @@ -1909,8 +1902,11 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault ); // Narrow tested variable to not late sentinel on false branch. - final currentTypeInformation = - stateWhenNotSentinel.readLocal(_inferrer, _capturedAndBoxed, local)!; + final currentTypeInformation = stateWhenNotSentinel.readLocal( + _inferrer, + _capturedAndBoxed, + local, + )!; stateWhenNotSentinel.updateLocal( _inferrer, _capturedAndBoxed, @@ -2164,12 +2160,11 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault LocalState stateAfterCheckWhenFalse = LocalState.childPath(_state); // Narrow variable to tested type on true branch. - final currentTypeInformation = - stateAfterCheckWhenTrue.readLocal( - _inferrer, - _capturedAndBoxed, - local, - )!; + final currentTypeInformation = stateAfterCheckWhenTrue.readLocal( + _inferrer, + _capturedAndBoxed, + local, + )!; stateAfterCheckWhenTrue.updateLocal( _inferrer, _capturedAndBoxed, @@ -2200,12 +2195,8 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault ); // Narrow tested variable to 'not null' on false branch. - TypeInformation currentTypeInformation = - stateAfterCheckWhenNotNull.readLocal( - _inferrer, - _capturedAndBoxed, - local, - )!; + TypeInformation currentTypeInformation = stateAfterCheckWhenNotNull + .readLocal(_inferrer, _capturedAndBoxed, local)!; stateAfterCheckWhenNotNull.updateLocal( _inferrer, _capturedAndBoxed, @@ -2277,13 +2268,12 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault final stateAfterRightWhenTrue = _stateAfterWhenTrue; final stateAfterRightWhenFalse = _stateAfterWhenFalse; final stateAfterWhenTrue = stateAfterRightWhenTrue; - LocalState stateAfterWhenFalse = LocalState.childPath( - stateBefore, - ).mergeDiamondFlow( - _inferrer, - stateAfterLeftWhenFalse, - stateAfterRightWhenFalse, - ); + LocalState stateAfterWhenFalse = LocalState.childPath(stateBefore) + .mergeDiamondFlow( + _inferrer, + stateAfterLeftWhenFalse, + stateAfterRightWhenFalse, + ); LocalState after = stateBefore.mergeDiamondFlow( _inferrer, stateAfterWhenTrue, @@ -2308,13 +2298,12 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault final rightInfo = handleCondition(node.right)!; final stateAfterRightWhenTrue = _stateAfterWhenTrue; final stateAfterRightWhenFalse = _stateAfterWhenFalse; - LocalState stateAfterWhenTrue = LocalState.childPath( - stateBefore, - ).mergeDiamondFlow( - _inferrer, - stateAfterLeftWhenTrue, - stateAfterRightWhenTrue, - ); + LocalState stateAfterWhenTrue = LocalState.childPath(stateBefore) + .mergeDiamondFlow( + _inferrer, + stateAfterLeftWhenTrue, + stateAfterRightWhenTrue, + ); LocalState stateAfterWhenFalse = stateAfterRightWhenFalse; LocalState stateAfter = stateBefore.mergeDiamondFlow( _inferrer, @@ -2552,13 +2541,12 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault // Continue with a copy of the state after the finalizer since control flow // should continue linearly. Update abort state to account for try/catch // aborting. - _state = - LocalState.childPath(_state) - ..seenReturnOrThrow = - _state.seenReturnOrThrow || stateBeforeFinalizer.seenReturnOrThrow - ..seenBreakOrContinue = - _state.seenBreakOrContinue || - stateBeforeFinalizer.seenBreakOrContinue; + _state = LocalState.childPath(_state) + ..seenReturnOrThrow = + _state.seenReturnOrThrow || stateBeforeFinalizer.seenReturnOrThrow + ..seenBreakOrContinue = + _state.seenBreakOrContinue || + stateBeforeFinalizer.seenBreakOrContinue; return null; } diff --git a/pkg/compiler/lib/src/inferrer/computable.dart b/pkg/compiler/lib/src/inferrer/computable.dart index 24993e2cf04..18bbcfd12d4 100644 --- a/pkg/compiler/lib/src/inferrer/computable.dart +++ b/pkg/compiler/lib/src/inferrer/computable.dart @@ -24,10 +24,9 @@ class ComputableAbstractValue implements AbstractValue { bool get isComputed => _wrappedValue != null; bool get isUncomputed => _wrappedValue == null; - AbstractValue _unwrapOrThrow() => - isUncomputed - ? throw StateError("Uncomputed abstract value") - : _wrappedValue!; + AbstractValue _unwrapOrThrow() => isUncomputed + ? throw StateError("Uncomputed abstract value") + : _wrappedValue!; AbstractValue _unwrapOrEmpty(AbstractValueDomain wrappedDomain) => isUncomputed ? wrappedDomain.emptyType : _wrappedValue!; diff --git a/pkg/compiler/lib/src/inferrer/engine.dart b/pkg/compiler/lib/src/inferrer/engine.dart index 37444cf98e0..ff0d90c63c9 100644 --- a/pkg/compiler/lib/src/inferrer/engine.dart +++ b/pkg/compiler/lib/src/inferrer/engine.dart @@ -754,10 +754,10 @@ class InferrerEngine { globalLocalsMap.getLocalsMap(member), node != null ? ir.StaticTypeContext( - node, - closedWorld.elementMap.typeEnvironment, - cache: ir.StaticTypeCacheImpl(), - ) + node, + closedWorld.elementMap.typeEnvironment, + cache: ir.StaticTypeCacheImpl(), + ) : null, memberHierarchyBuilder, ); diff --git a/pkg/compiler/lib/src/inferrer/locals_handler.dart b/pkg/compiler/lib/src/inferrer/locals_handler.dart index 9e2fa0becc0..07f221bb507 100644 --- a/pkg/compiler/lib/src/inferrer/locals_handler.dart +++ b/pkg/compiler/lib/src/inferrer/locals_handler.dart @@ -50,15 +50,15 @@ class VariableScope { } VariableScope.deepCopyOf(VariableScope other) - : variables = - other.variables == null - ? null - : Map.from(other.variables!), + : variables = other.variables == null + ? null + : Map.from(other.variables!), tryBlock = other.tryBlock, copyOf = other.copyOf ?? other, _level = other._level, - parent = - other.parent == null ? null : VariableScope.deepCopyOf(other.parent!); + parent = other.parent == null + ? null + : VariableScope.deepCopyOf(other.parent!); /// `true` if this scope is for a try block. bool get isTry => tryBlock != null; @@ -224,8 +224,9 @@ class FieldInitializationScope { if (isThisExposed) return this; if (isIndefinite) return this; - FieldInitializationScope otherScope = - elseScope.fields == null ? this : elseScope; + FieldInitializationScope otherScope = elseScope.fields == null + ? this + : elseScope; thenScope.forEach((FieldEntity field, TypeInformation type) { final otherType = otherScope.readField(field); @@ -400,8 +401,9 @@ class LocalsHandler { final myType = _locals[local]; if (myType == null) return; // Variable is only defined in [other]. if (type == myType) return; - _locals[local] = - inPlace ? type : inferrer.types.allocateDiamondPhi(myType, type); + _locals[local] = inPlace + ? type + : inferrer.types.allocateDiamondPhi(myType, type); }); return this; } @@ -493,10 +495,9 @@ class LocalsHandler { // Use a separate locals handler to perform the merge in, so that Phi // creation does not invalidate previous type knowledge while we might // still look it up. - VariableScope merged = - tryBlock != null - ? VariableScope.tryBlock(tryBlock, parent: _locals) - : VariableScope(parent: _locals); + VariableScope merged = tryBlock != null + ? VariableScope.tryBlock(tryBlock, parent: _locals) + : VariableScope(parent: _locals); Map seenLocals = {}; // Merge all other handlers. for (LocalsHandler handler in handlers) { diff --git a/pkg/compiler/lib/src/inferrer/type_graph_dump.dart b/pkg/compiler/lib/src/inferrer/type_graph_dump.dart index 1ea75b91b07..fc638cdd870 100644 --- a/pkg/compiler/lib/src/inferrer/type_graph_dump.dart +++ b/pkg/compiler/lib/src/inferrer/type_graph_dump.dart @@ -310,8 +310,9 @@ class _GraphGenerator extends TypeInformationVisitor { var tracerSet = global.assignmentsBeforeTracing[node] ?? const {}; var currentSet = node.inputs.toSet(); for (TypeInformation assignment in currentSet) { - String color = - originalSet.contains(assignment) ? unchangedEdge : addedEdge; + String color = originalSet.contains(assignment) + ? unchangedEdge + : addedEdge; addEdge(assignment, node, color: color); } for (TypeInformation assignment in originalSet) { diff --git a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart index a29c11f20af..e9d598de8d6 100644 --- a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart +++ b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart @@ -156,10 +156,9 @@ abstract class TypeInformation { void incrementRefineCount() => _flags = EnumSet.fromRawBits(_flags.mask.bits + (1 << numTypeInfoFlags)); - void clearRefineCount() => - _flags = EnumSet.fromRawBits( - _flags.mask.bits & ((1 << numTypeInfoFlags) - 1), - ); + void clearRefineCount() => _flags = EnumSet.fromRawBits( + _flags.mask.bits & ((1 << numTypeInfoFlags) - 1), + ); void addUser(TypeInformation user) { assert(!user.isConcrete); @@ -654,10 +653,9 @@ class GetterTypeInformation extends MemberTypeInformation { AbstractValueDomain abstractValueDomain, this._member, FunctionType type, - ) : _type = - abstractValueDomain - .createFromStaticType(type.returnType) - .abstractValue, + ) : _type = abstractValueDomain + .createFromStaticType(type.returnType) + .abstractValue, super._internal(abstractValueDomain, _member); @override @@ -704,10 +702,9 @@ class MethodTypeInformation extends MemberTypeInformation { AbstractValueDomain abstractValueDomain, this._member, FunctionType type, - ) : _type = - abstractValueDomain - .createFromStaticType(type.returnType) - .abstractValue, + ) : _type = abstractValueDomain + .createFromStaticType(type.returnType) + .abstractValue, super._internal(abstractValueDomain, _member); @override @@ -739,10 +736,9 @@ class FactoryConstructorTypeInformation extends MemberTypeInformation { AbstractValueDomain abstractValueDomain, this._member, FunctionType type, - ) : _type = - abstractValueDomain - .createFromStaticType(type.returnType) - .abstractValue, + ) : _type = abstractValueDomain + .createFromStaticType(type.returnType) + .abstractValue, super._internal(abstractValueDomain, _member); @override @@ -797,10 +793,9 @@ class GenerativeConstructorTypeInformation extends MemberTypeInformation { return _narrowType( inferrer.abstractValueDomain, mask, - _baseType ??= - cls.isAbstract - ? inferrer.abstractValueDomain.createNonNullSubclass(cls) - : inferrer.abstractValueDomain.createNonNullExact(cls), + _baseType ??= cls.isAbstract + ? inferrer.abstractValueDomain.createNonNullSubclass(cls) + : inferrer.abstractValueDomain.createNonNullExact(cls), ); } } @@ -962,10 +957,9 @@ class ParameterTypeInformation extends ElementTypeInformation { AbstractValue mask, InferrerEngine inferrer, ) { - final staticType = - isOptionalNoDefault - ? inferrer.abstractValueDomain.includeNull(_type) - : _type; + final staticType = isOptionalNoDefault + ? inferrer.abstractValueDomain.includeNull(_type) + : _type; return _narrowType(inferrer.abstractValueDomain, mask, staticType); } @@ -1253,11 +1247,10 @@ class DynamicCallSiteTypeInformation selector!, typeMask, ); - final targets = - _targets = inferrer.memberHierarchyBuilder.rootsForCall( - typeMask, - selector!, - ); + final targets = _targets = inferrer.memberHierarchyBuilder.rootsForCall( + typeMask, + selector!, + ); invalidateTargetsIncludeComplexNoSuchMethod(); receiver.addUser(this); if (arguments != null) { @@ -1351,10 +1344,9 @@ class DynamicCallSiteTypeInformation abstractValueDomain.isIntegerOrNull(info.type).isDefinitelyTrue; bool isEmpty(TypeInformation info) => abstractValueDomain.isEmpty(info.type).isDefinitelyTrue; - bool isUInt31(TypeInformation info) => - abstractValueDomain - .isUInt31(abstractValueDomain.excludeNull(info.type)) - .isDefinitelyTrue; + bool isUInt31(TypeInformation info) => abstractValueDomain + .isUInt31(abstractValueDomain.excludeNull(info.type)) + .isDefinitelyTrue; bool isPositiveInt(TypeInformation info) => abstractValueDomain.isPositiveIntegerOrNull(info.type).isDefinitelyTrue; @@ -1451,16 +1443,12 @@ class DynamicCallSiteTypeInformation typeMask, ); - final includesClosureCall = - _hasClosureCallTargets = closedWorld.includesClosureCall( - localSelector, - typeMask, - ); - final targets = - _targets = inferrer.memberHierarchyBuilder.rootsForCall( - typeMask, - localSelector, - ); + final includesClosureCall = _hasClosureCallTargets = closedWorld + .includesClosureCall(localSelector, typeMask); + final targets = _targets = inferrer.memberHierarchyBuilder.rootsForCall( + typeMask, + localSelector, + ); // Update the call graph if the targets could have changed. if (!identical(targets, oldTargets)) { @@ -1581,11 +1569,8 @@ class DynamicCallSiteTypeInformation localSelector, mask, ); - final newTargets = - _targets = inferrer.memberHierarchyBuilder.rootsForCall( - mask, - localSelector, - ); + final newTargets = _targets = inferrer.memberHierarchyBuilder + .rootsForCall(mask, localSelector); invalidateTargetsIncludeComplexNoSuchMethod(); for (final target in newTargets) { if (!oldTargets.contains(target)) { @@ -2346,10 +2331,9 @@ class RecordTypeInformation extends TypeInformation with TracedTypeInformation { @override AbstractValue safeType(InferrerEngine inferrer) { - final shapeClass = - inferrer.closedWorld.recordData - .representationForShape(recordShape) - ?.cls; + final shapeClass = inferrer.closedWorld.recordData + .representationForShape(recordShape) + ?.cls; return shapeClass != null ? inferrer.abstractValueDomain.createNonNullSubtype(shapeClass) : inferrer.abstractValueDomain.recordType; diff --git a/pkg/compiler/lib/src/inferrer/type_system.dart b/pkg/compiler/lib/src/inferrer/type_system.dart index 7f574d5657c..f53d308cebc 100644 --- a/pkg/compiler/lib/src/inferrer/type_system.dart +++ b/pkg/compiler/lib/src/inferrer/type_system.dart @@ -339,8 +339,9 @@ class TypeSystem { return excludeLateSentinel0(); } - AbstractValue narrowing = - _abstractValueDomain.createFromStaticType(annotation).abstractValue; + AbstractValue narrowing = _abstractValueDomain + .createFromStaticType(annotation) + .abstractValue; if (excludeNull) { narrowing = _abstractValueDomain.excludeNull(narrowing); @@ -376,10 +377,9 @@ class TypeSystem { Local parameter, { bool isVirtual = false, }) { - final typeInformations = - isVirtual - ? virtualParameterTypeInformations - : parameterTypeInformations; + final typeInformations = isVirtual + ? virtualParameterTypeInformations + : parameterTypeInformations; return typeInformations.putIfAbsent(parameter, () { ParameterTypeInformation typeInformation = strategy .createParameterTypeInformation( @@ -489,8 +489,9 @@ class TypeSystem { bool isElementInferred = isConst || isTypedArray; final inferredLength = isFixed ? length : null; - final elementTypeMask = - isElementInferred ? elementType.type : dynamicType.type; + final elementTypeMask = isElementInferred + ? elementType.type + : dynamicType.type; AbstractValue mask = _abstractValueDomain.createContainerValue( type.type, node, @@ -538,8 +539,9 @@ class TypeSystem { assert(strategy.checkSetNode(node)); bool isConst = type.type == _abstractValueDomain.constSetType; - AbstractValue elementTypeMask = - isConst ? elementType.type : dynamicType.type; + AbstractValue elementTypeMask = isConst + ? elementType.type + : dynamicType.type; AbstractValue mask = _abstractValueDomain.createSetValue( type.type, node, @@ -577,22 +579,22 @@ class TypeSystem { PhiElementTypeInformation? keyType, valueType; for (int i = 0; i < keyTypes.length; ++i) { final typeForKey = keyTypes[i]; - keyType = - keyType == null - ? allocatePhi(null, null, typeForKey, isTry: false) - : addPhiInput(null, keyType, typeForKey); + keyType = keyType == null + ? allocatePhi(null, null, typeForKey, isTry: false) + : addPhiInput(null, keyType, typeForKey); final typeForValue = valueTypes[i]; - valueType = - valueType == null - ? allocatePhi(null, null, typeForValue, isTry: false) - : addPhiInput(null, valueType, typeForValue); + valueType = valueType == null + ? allocatePhi(null, null, typeForValue, isTry: false) + : addPhiInput(null, valueType, typeForValue); } - final simplifiedKeyType = - keyType == null ? nonNullEmpty() : simplifyPhi(null, null, keyType); - final simplifiedValueType = - valueType == null ? nonNullEmpty() : simplifyPhi(null, null, valueType); + final simplifiedKeyType = keyType == null + ? nonNullEmpty() + : simplifyPhi(null, null, keyType); + final simplifiedValueType = valueType == null + ? nonNullEmpty() + : simplifyPhi(null, null, valueType); AbstractValue keyTypeMask, valueTypeMask; if (isFixed) { @@ -847,8 +849,9 @@ class TypeSystem { AbstractValue? newType; for (AbstractValue mask in list) { - newType = - newType == null ? mask : _abstractValueDomain.union(newType, mask); + newType = newType == null + ? mask + : _abstractValueDomain.union(newType, mask); // Likewise - stop early if we already reach dynamic. if (_abstractValueDomain.containsAll(newType).isPotentiallyTrue) { isTopIgnoringFlags = true; diff --git a/pkg/compiler/lib/src/inferrer/typemasks/flat_type_mask.dart b/pkg/compiler/lib/src/inferrer/typemasks/flat_type_mask.dart index 8789af5c45e..ce821561742 100644 --- a/pkg/compiler/lib/src/inferrer/typemasks/flat_type_mask.dart +++ b/pkg/compiler/lib/src/inferrer/typemasks/flat_type_mask.dart @@ -105,10 +105,9 @@ class FlatTypeMask extends TypeMask { CommonMasks domain, { bool hasLateSentinel = false, }) { - final powerset = - hasLateSentinel - ? _specialValueDomain.fromValue(TypeMaskSpecialValue.lateSentinel) - : Bitset.empty(); + final powerset = hasLateSentinel + ? _specialValueDomain.fromValue(TypeMaskSpecialValue.lateSentinel) + : Bitset.empty(); return FlatTypeMask._emptyOrSpecial(domain, powerset); } @@ -117,10 +116,9 @@ class FlatTypeMask extends TypeMask { CommonMasks domain, { bool hasLateSentinel = false, }) { - final powerset = - hasLateSentinel - ? _specialValueDomain.allValues - : _specialValueDomain.fromValue(TypeMaskSpecialValue.null_); + final powerset = hasLateSentinel + ? _specialValueDomain.allValues + : _specialValueDomain.fromValue(TypeMaskSpecialValue.null_); return FlatTypeMask._emptyOrSpecial(domain, powerset); } @@ -180,8 +178,9 @@ class FlatTypeMask extends TypeMask { final probe = domain._powersetCache[base]; final powerset = switch (kind) { - FlatTypeMaskKind.empty => - throw StateError('Unexpected empty kind with base $base'), + FlatTypeMaskKind.empty => throw StateError( + 'Unexpected empty kind with base $base', + ), FlatTypeMaskKind.exact => probe.exact, FlatTypeMaskKind.subclass => probe.subclass, FlatTypeMaskKind.subtype => probe.subtype, @@ -266,10 +265,9 @@ class FlatTypeMask extends TypeMask { @override Bitset get powerset => _getPowerset(_flags); - ClassQuery get _classQuery => - isExact - ? ClassQuery.exact - : (isSubclass ? ClassQuery.subclass : ClassQuery.subtype); + ClassQuery get _classQuery => isExact + ? ClassQuery.exact + : (isSubclass ? ClassQuery.subclass : ClassQuery.subtype); @override bool get isEmpty => @@ -551,11 +549,11 @@ class FlatTypeMask extends TypeMask { // If we weaken the constraint on this type, we have to make sure that // the result is normalized. : FlatTypeMask.normalized( - base!, - combinedKind, - combinedPowerset, - domain, - ); + base!, + combinedKind, + combinedPowerset, + domain, + ); } @override @@ -594,9 +592,9 @@ class FlatTypeMask extends TypeMask { return includeNull ? TypeMask.empty(domain, hasLateSentinel: includeLateSentinel) : TypeMask.nonNullEmpty( - domain, - hasLateSentinel: includeLateSentinel, - ); + domain, + hasLateSentinel: includeLateSentinel, + ); case SimpleSubclassResult.exact1: assert(isExact); return withPowerset(powerset, domain); @@ -620,22 +618,22 @@ class FlatTypeMask extends TypeMask { return includeNull ? TypeMask.empty(domain, hasLateSentinel: includeLateSentinel) : TypeMask.nonNullEmpty( - domain, - hasLateSentinel: includeLateSentinel, - ); + domain, + hasLateSentinel: includeLateSentinel, + ); } else if (classes.length == 1) { ClassEntity cls = classes.first; return includeNull ? TypeMask.subclass( - cls, - domain, - hasLateSentinel: includeLateSentinel, - ) + cls, + domain, + hasLateSentinel: includeLateSentinel, + ) : TypeMask.nonNullSubclass( - cls, - domain, - hasLateSentinel: includeLateSentinel, - ); + cls, + domain, + hasLateSentinel: includeLateSentinel, + ); } List masks = List.from( @@ -692,10 +690,9 @@ class FlatTypeMask extends TypeMask { assert(a.isSubclass || a.isSubtype); assert(b.isSubtype); final aBase = a.base!; - var elements = - a.isSubclass - ? closedWorld.classHierarchy.strictSubclassesOf(aBase) - : closedWorld.classHierarchy.strictSubtypesOf(aBase); + var elements = a.isSubclass + ? closedWorld.classHierarchy.strictSubclassesOf(aBase) + : closedWorld.classHierarchy.strictSubtypesOf(aBase); for (var element in elements) { if (closedWorld.classHierarchy.isSubtypeOf(element, b.base!)) { return false; @@ -882,18 +879,15 @@ class _PowersetCache { final Map _cache = {}; _PowersetCache(this._closedWorld) - : _interceptorCone = - _closedWorld.classHierarchy - .subclassesOf(_closedWorld.commonElements.jsInterceptorClass) - .toSet(), - _indexableCone = - _closedWorld.classHierarchy - .subtypesOf(_closedWorld.commonElements.jsIndexableClass) - .toSet(), - _mutableIndexableCone = - _closedWorld.classHierarchy - .subtypesOf(_closedWorld.commonElements.jsMutableIndexableClass) - .toSet(); + : _interceptorCone = _closedWorld.classHierarchy + .subclassesOf(_closedWorld.commonElements.jsInterceptorClass) + .toSet(), + _indexableCone = _closedWorld.classHierarchy + .subtypesOf(_closedWorld.commonElements.jsIndexableClass) + .toSet(), + _mutableIndexableCone = _closedWorld.classHierarchy + .subtypesOf(_closedWorld.commonElements.jsMutableIndexableClass) + .toSet(); Bitset _computeExactPowerset(ClassEntity cls) { var powerset = Bitset.empty(); diff --git a/pkg/compiler/lib/src/inferrer/typemasks/masks.dart b/pkg/compiler/lib/src/inferrer/typemasks/masks.dart index 454f69721ab..efe0ad09c18 100644 --- a/pkg/compiler/lib/src/inferrer/typemasks/masks.dart +++ b/pkg/compiler/lib/src/inferrer/typemasks/masks.dart @@ -460,10 +460,9 @@ class CommonMasks with AbstractValueDomain { covariant TypeMask expressionMask, ClassEntity cls, ) { - final typeMask = - (cls == commonElements.nullClass) - ? nullType - : createNonNullSubtype(cls); + final typeMask = (cls == commonElements.nullClass) + ? nullType + : createNonNullSubtype(cls); if (expressionMask.union(typeMask, this) == typeMask) { return AbstractBool.true_; } else if (expressionMask.isDisjoint(typeMask, closedWorld)) { @@ -756,11 +755,10 @@ class CommonMasks with AbstractValueDomain { AbstractBool isPrimitiveOrNull(TypeMask value) => AbstractBool.trueOrMaybe(_isPrimitiveOrNull(value)); - bool _isIndexable(TypeMask value) => - !_indexableDomain.contains( - value.powerset, - TypeMaskIndexableProperty.notIndexable, - ); + bool _isIndexable(TypeMask value) => !_indexableDomain.contains( + value.powerset, + TypeMaskIndexableProperty.notIndexable, + ); bool _isIndexablePrimitive(TypeMask value) => value.containsOnlyString(closedWorld) || _isIndexable(value); @@ -984,8 +982,9 @@ class CommonMasks with AbstractValueDomain { @override AbstractValue getDictionaryValueForKey(AbstractValue value, String key) { - final result = - value is DictionaryTypeMask ? value.getValueForKey(key) : null; + final result = value is DictionaryTypeMask + ? value.getValueForKey(key) + : null; return result ?? dynamicType; } @@ -1221,12 +1220,11 @@ String formatType(DartTypes dartTypes, TypeMask type) { ].join(''); } String nullFlag = type.isNullable ? '?' : ''; - String subFlag = - type.isExact - ? '' - : type.isSubclass - ? '+' - : '*'; + String subFlag = type.isExact + ? '' + : type.isSubclass + ? '+' + : '*'; String sentinelFlag = type.hasLateSentinel ? '\$' : ''; return '${type.base!.name}$nullFlag$subFlag$sentinelFlag'; } diff --git a/pkg/compiler/lib/src/inferrer/typemasks/record_type_mask.dart b/pkg/compiler/lib/src/inferrer/typemasks/record_type_mask.dart index 3ba0a225cd5..4608ce0a6bd 100644 --- a/pkg/compiler/lib/src/inferrer/typemasks/record_type_mask.dart +++ b/pkg/compiler/lib/src/inferrer/typemasks/record_type_mask.dart @@ -374,27 +374,27 @@ class RecordTypeMask extends TypeMask { if (domain.closedWorld.classHierarchy.hasAnyStrictSubclass(recordClass)) { return isNullable ? FlatTypeMask.subclass( - recordClass, - domain, - hasLateSentinel: hasLateSentinel, - ) + recordClass, + domain, + hasLateSentinel: hasLateSentinel, + ) : FlatTypeMask.nonNullSubclass( - recordClass, - domain, - hasLateSentinel: hasLateSentinel, - ); + recordClass, + domain, + hasLateSentinel: hasLateSentinel, + ); } else { return isNullable ? FlatTypeMask.exact( - recordClass, - domain, - hasLateSentinel: hasLateSentinel, - ) + recordClass, + domain, + hasLateSentinel: hasLateSentinel, + ) : FlatTypeMask.nonNullExact( - recordClass, - domain, - hasLateSentinel: hasLateSentinel, - ); + recordClass, + domain, + hasLateSentinel: hasLateSentinel, + ); } } diff --git a/pkg/compiler/lib/src/inferrer/typemasks/type_mask.dart b/pkg/compiler/lib/src/inferrer/typemasks/type_mask.dart index 6d306721703..dda3312a5b5 100644 --- a/pkg/compiler/lib/src/inferrer/typemasks/type_mask.dart +++ b/pkg/compiler/lib/src/inferrer/typemasks/type_mask.dart @@ -747,13 +747,12 @@ abstract class TypeMask implements AbstractValue { } String domainToString(EnumSetDomain domain) { - final mnemonics = - domain - .toEnumSet(powerset) - .iterable(domain.values) - .toList() - .reversed - .join(); + final mnemonics = domain + .toEnumSet(powerset) + .iterable(domain.values) + .toList() + .reversed + .join(); return '{$mnemonics}'; } diff --git a/pkg/compiler/lib/src/inferrer/typemasks/union_type_mask.dart b/pkg/compiler/lib/src/inferrer/typemasks/union_type_mask.dart index b30d9b2972e..385a38c8ab1 100644 --- a/pkg/compiler/lib/src/inferrer/typemasks/union_type_mask.dart +++ b/pkg/compiler/lib/src/inferrer/typemasks/union_type_mask.dart @@ -105,10 +105,9 @@ class UnionTypeMask extends TypeMask { } else if (mask.isEmpty) { continue; } else { - var flatMask = - mask is RecordTypeMask - ? mask.toFlatTypeMask(domain) - : mask as FlatTypeMask; + var flatMask = mask is RecordTypeMask + ? mask.toFlatTypeMask(domain) + : mask as FlatTypeMask; int inListIndex = -1; bool covered = false; diff --git a/pkg/compiler/lib/src/inferrer/types.dart b/pkg/compiler/lib/src/inferrer/types.dart index 7bf02ee231e..d1302e7cf59 100644 --- a/pkg/compiler/lib/src/inferrer/types.dart +++ b/pkg/compiler/lib/src/inferrer/types.dart @@ -205,13 +205,12 @@ class GlobalTypeInferenceTask extends CompilerTask { globalLocalsMap, ); } else { - final inferrer = - typesInferrerInternal ??= compiler.backendStrategy - .createTypesInferrer( - closedWorld, - globalLocalsMap, - inferredDataBuilder, - ); + final inferrer = typesInferrerInternal ??= compiler.backendStrategy + .createTypesInferrer( + closedWorld, + globalLocalsMap, + inferredDataBuilder, + ); results = inferrer.analyzeMain(mainElement); _metrics = inferrer.metrics; } @@ -310,8 +309,9 @@ class GlobalTypeInferenceResultsImpl implements GlobalTypeInferenceResults { .readAbstractValueFromDataSource(source), ), ); - Set returnsListElementTypeSet = - source.readList(() => Selector.readFromDataSource(source)).toSet(); + Set returnsListElementTypeSet = source + .readList(() => Selector.readFromDataSource(source)) + .toSet(); Deferrable> allocatedLists = source .readDeferrable( (source) => source.readTreeNodeMap( diff --git a/pkg/compiler/lib/src/io/kernel_source_information.dart b/pkg/compiler/lib/src/io/kernel_source_information.dart index e32e29cb2bf..0eec0df473f 100644 --- a/pkg/compiler/lib/src/io/kernel_source_information.dart +++ b/pkg/compiler/lib/src/io/kernel_source_information.dart @@ -68,8 +68,10 @@ String? computeKernelElementNameForSourceMaps( node = node.parent!; } MemberEntity enclosingMember = elementMap.getMember(node); - String enclosingMemberName = - computeElementNameForSourceMaps(enclosingMember, callStructure)!; + String enclosingMemberName = computeElementNameForSourceMaps( + enclosingMember, + callStructure, + )!; return '$enclosingMemberName.$name'; case MemberKind.constructor: case MemberKind.constructorBody: diff --git a/pkg/compiler/lib/src/io/position_information.dart b/pkg/compiler/lib/src/io/position_information.dart index 0790058e50b..459892f8c22 100644 --- a/pkg/compiler/lib/src/io/position_information.dart +++ b/pkg/compiler/lib/src/io/position_information.dart @@ -46,15 +46,17 @@ class PositionSourceInformation extends SourceInformation { .readIndexedOrNullNoCache( () => SourceLocation.readFromDataSource(source), ); - List? - inliningContext = source.readIndexedOrNullNoCache>( - () => - // FrameContext must be cached since PositionSourceInformation.== - // requires identity comparison on the objects in inliningContext. - source.readList( - () => source.readIndexed(() => FrameContext.readFromDataSource(source)), - ), - ); + List? inliningContext = source + .readIndexedOrNullNoCache>( + () => + // FrameContext must be cached since PositionSourceInformation.== + // requires identity comparison on the objects in inliningContext. + source.readList( + () => source.readIndexed( + () => FrameContext.readFromDataSource(source), + ), + ), + ); source.end(tag); return PositionSourceInformation( startPosition, @@ -1161,10 +1163,9 @@ class OnlineJavaScriptTracer extends js.BaseVisitor1Void node, _currentNode, active: _currentNode.active, - branchData: - branchKind == null - ? null - : _BranchData(branchKind, branchNotificationMode, branchToken), + branchData: branchKind == null + ? null + : _BranchData(branchKind, branchNotificationMode, branchToken), statementOffset: statementOffset ?? _currentNode.statementOffset, offsetPositionMode: offsetPositionMode, steps: resetSteps ? [] : _currentNode.steps, @@ -1284,12 +1285,8 @@ class OnlineJavaScriptTracer extends js.BaseVisitor1Void counter: value.counter + 1, position: value.position, ), - ifAbsent: - () => ( - kind: callPosition.codePositionKind, - counter: 1, - position: null, - ), + ifAbsent: () => + (kind: callPosition.codePositionKind, counter: 1, position: null), ); } _currentNode.addNotifyStep(StepKind.call); @@ -1495,8 +1492,12 @@ class OnlineJavaScriptTracer extends js.BaseVisitor1Void notifyStart(node); // Create empty node as root of tree. - _rootNode = - _currentNode = _PositionInfoNode(node, null, active: false, steps: []); + _rootNode = _currentNode = _PositionInfoNode( + node, + null, + active: false, + steps: [], + ); Offset startOffset = getOffsetForNode(null, startPosition); notifyStep(node, startOffset, StepKind.noInfo, force: true); diff --git a/pkg/compiler/lib/src/ir/protobuf_impacts.dart b/pkg/compiler/lib/src/ir/protobuf_impacts.dart index 1c41fd56de2..52e3b9b354a 100644 --- a/pkg/compiler/lib/src/ir/protobuf_impacts.dart +++ b/pkg/compiler/lib/src/ir/protobuf_impacts.dart @@ -147,11 +147,11 @@ class ProtobufImpactHandler implements ConditionalImpactHandler { ); late final ir.Procedure _builderInfoAddMethod = _elementMap.env.libraryIndex .getProcedure(protobufLibraryUri, 'BuilderInfo', 'add'); - late final ir.FunctionType _typeOfBuilderInfoAddOfNull = ir - .FunctionTypeInstantiator.instantiate( - _builderInfoAddMethod.getterType as ir.FunctionType, - const [ir.NullType()], - ); + late final ir.FunctionType _typeOfBuilderInfoAddOfNull = + ir.FunctionTypeInstantiator.instantiate( + _builderInfoAddMethod.getterType as ir.FunctionType, + const [ir.NullType()], + ); late final ir.Procedure? _builderInfoAddUnusedMethod = _elementMap .env @@ -232,9 +232,9 @@ class ProtobufImpactHandler implements ConditionalImpactHandler { // conditional on the associated field being reachable. return _impactData = interfaceTarget.enclosingClass == _builderInfoClass && - metadataInitializers.contains(node.name.text) - ? ImpactData() - : null; + metadataInitializers.contains(node.name.text) + ? ImpactData() + : null; } @override diff --git a/pkg/compiler/lib/src/ir/scope.dart b/pkg/compiler/lib/src/ir/scope.dart index 8d4927bef39..1d82bfcc740 100644 --- a/pkg/compiler/lib/src/ir/scope.dart +++ b/pkg/compiler/lib/src/ir/scope.dart @@ -98,8 +98,9 @@ mixin VariableCollectorMixin { void visitInVariableScope(ir.TreeNode root, void Function() f) { VariableScopeImpl? oldScope = currentVariableScope; - final newScope = - currentVariableScope = variableScopeModel.createScopeFor(root); + final newScope = currentVariableScope = variableScopeModel.createScopeFor( + root, + ); oldScope?.addSubScope(newScope); f(); currentVariableScope = oldScope; diff --git a/pkg/compiler/lib/src/ir/scope_visitor.dart b/pkg/compiler/lib/src/ir/scope_visitor.dart index e761a9757cb..0bdaa57c06f 100644 --- a/pkg/compiler/lib/src/ir/scope_visitor.dart +++ b/pkg/compiler/lib/src/ir/scope_visitor.dart @@ -141,8 +141,9 @@ class ScopeModelBuilder extends ir.VisitorDefault /// This method should be called in the visit methods of all expressions that /// could potentially be constant to bubble up the constness of expressions. EvaluationComplexity _evaluateImplicitConstant(ir.Expression node) { - ir.Constant? constant = - (node is ir.ConstantExpression) ? node.constant : null; + ir.Constant? constant = (node is ir.ConstantExpression) + ? node.constant + : null; if (constant != null) { return EvaluationComplexity.constant(constant); } @@ -865,10 +866,9 @@ class ScopeModelBuilder extends ir.VisitorDefault @override EvaluationComplexity visitFunctionNode(ir.FunctionNode node) { final parent = node.parent; - VariableUse parameterUsage = - parent is ir.Member - ? MemberParameterVariableUse(parent) - : LocalParameterVariableUse(parent as ir.LocalFunction); + VariableUse parameterUsage = parent is ir.Member + ? MemberParameterVariableUse(parent) + : LocalParameterVariableUse(parent as ir.LocalFunction); visitNodesInContext(node.typeParameters, parameterUsage); for (ir.VariableDeclaration declaration in node.positionalParameters) { _handleVariableDeclaration(declaration, parameterUsage); diff --git a/pkg/compiler/lib/src/js/rewrite_async.dart b/pkg/compiler/lib/src/js/rewrite_async.dart index 6e8fcb8ada7..b141820d454 100644 --- a/pkg/compiler/lib/src/js/rewrite_async.dart +++ b/pkg/compiler/lib/src/js/rewrite_async.dart @@ -754,10 +754,9 @@ abstract class AsyncRewriterBase extends js.NodeVisitor { beginLabel(newLabel("Function start")); // AsyncStar needs a return label for its handling of cancellation. See // [visitDartYield]. - exitLabel = - (analysis.hasExplicitReturns || isAsyncStar) - ? newLabel("return") - : null; + exitLabel = (analysis.hasExplicitReturns || isAsyncStar) + ? newLabel("return") + : null; handlerLabels[node] = rethrowLabel = newLabel("rethrow"); js.Statement body = node.body; jumpTargets.add(node); @@ -836,8 +835,9 @@ abstract class AsyncRewriterBase extends js.NodeVisitor { js.VariableDeclarationList(variables); // Names are already safe when added. - List typeParameters = - typeArgumentNames.map((name) => js.Parameter(name)).toList(); + List typeParameters = typeArgumentNames + .map((name) => js.Parameter(name)) + .toList(); return finishFunction( node.params, typeParameters, @@ -968,10 +968,9 @@ abstract class AsyncRewriterBase extends js.NodeVisitor { int thenLabel = newLabel("then"); int joinLabel = newLabel("join"); withExpression(node.left, (js.Expression left) { - js.Statement assignLeft = - isResult(left) - ? js.Block.empty() - : js.js.statement('# = #;', [result, left]); + js.Statement assignLeft = isResult(left) + ? js.Block.empty() + : js.js.statement('# = #;', [result, left]); if (node.op == "&&") { addStatement( js.js.statement('if (#) #; else #', [ @@ -1240,8 +1239,9 @@ abstract class AsyncRewriterBase extends js.NodeVisitor { int startLabel = newLabel("for condition"); // If there is no update, continuing the loop is the same as going to the // start. - int continueLabel = - (node.update == null) ? startLabel : newLabel("for update"); + int continueLabel = (node.update == null) + ? startLabel + : newLabel("for update"); continueLabels[node] = continueLabel; int afterLabel = newLabel("after for"); breakLabels[node] = afterLabel; @@ -1314,8 +1314,9 @@ abstract class AsyncRewriterBase extends js.NodeVisitor { } int thenLabel = newLabel("then"); int joinLabel = newLabel("join"); - int elseLabel = - (node.otherwise is js.EmptyStatement) ? joinLabel : newLabel("else"); + int elseLabel = (node.otherwise is js.EmptyStatement) + ? joinLabel + : newLabel("else"); withExpression(node.condition, (js.Expression condition) { addExpressionStatement( @@ -1571,19 +1572,13 @@ abstract class AsyncRewriterBase extends js.NodeVisitor { bool oldInsideUntranslated = insideUntranslatedBreakable; insideUntranslatedBreakable = true; withExpression(node.key, (js.Expression key) { - List cases = - node.cases.map((js.SwitchClause clause) { - if (clause is js.Case) { - return js.Case( - clause.expression, - translateToBlock(clause.body), - ); - } else { - return js.Default( - translateToBlock((clause as js.Default).body), - ); - } - }).toList(); + List cases = node.cases.map((js.SwitchClause clause) { + if (clause is js.Case) { + return js.Case(clause.expression, translateToBlock(clause.body)); + } else { + return js.Default(translateToBlock((clause as js.Default).body)); + } + }).toList(); addStatement(js.Switch(key, cases)); }, store: false); insideUntranslatedBreakable = oldInsideUntranslated; @@ -1691,8 +1686,9 @@ abstract class AsyncRewriterBase extends js.NodeVisitor { void setErrorHandler([int? errorHandler]) { hasHandlerLabels = true; // TODO(sra): Add short form error handler. - js.Expression label = - (errorHandler == null) ? currentErrorHandler : js.number(errorHandler); + js.Expression label = (errorHandler == null) + ? currentErrorHandler + : js.number(errorHandler); addStatement(js.js.statement('# = #;', [handler, label])); } @@ -1736,8 +1732,9 @@ abstract class AsyncRewriterBase extends js.NodeVisitor { ); variableRenamings.removeLast(); } - js.Block? translatedFinallyPart = - (finallyPart == null) ? null : translateToBlock(finallyPart); + js.Block? translatedFinallyPart = (finallyPart == null) + ? null + : translateToBlock(finallyPart); addStatement(js.Try(body, translatedCatchPart, translatedFinallyPart)); return; } @@ -2057,8 +2054,9 @@ class AsyncRewriter extends AsyncRewriterBase { js.Expression runtimeHelperCall = js .js("#runtimeHelper(#returnValue, #completer)", { "runtimeHelper": asyncReturn, - "returnValue": - analysis.hasExplicitReturns ? returnValue : js.LiteralNull(), + "returnValue": analysis.hasExplicitReturns + ? returnValue + : js.LiteralNull(), "completer": completer, }) .withSourceInformation(sourceInformation); @@ -2574,8 +2572,9 @@ class AsyncStarRewriter extends AsyncRewriterBase { ); js.Expression yieldExpressionCall = js .js("#yieldExpression(#expression)", { - "yieldExpression": - node.hasStar ? yieldStarExpression : yieldExpression, + "yieldExpression": node.hasStar + ? yieldStarExpression + : yieldExpression, "expression": expression, }) .withSourceInformation(sourceInformation); @@ -3260,8 +3259,9 @@ class PreTranslationAnalysis extends js.BaseVisitor { if (node.finallyPart != null) hasFinally = true; bool body = visit(node.body); bool catchPart = (node.catchPart == null) ? false : visit(node.catchPart!); - bool finallyPart = - (node.finallyPart == null) ? false : visit(node.finallyPart!); + bool finallyPart = (node.finallyPart == null) + ? false + : visit(node.finallyPart!); return body || catchPart || finallyPart; } diff --git a/pkg/compiler/lib/src/js_backend/backend_usage.dart b/pkg/compiler/lib/src/js_backend/backend_usage.dart index 02b01662b20..08bf255e37d 100644 --- a/pkg/compiler/lib/src/js_backend/backend_usage.dart +++ b/pkg/compiler/lib/src/js_backend/backend_usage.dart @@ -297,19 +297,20 @@ class BackendUsageImpl implements BackendUsage { factory BackendUsageImpl.readFromDataSource(DataSourceReader source) { source.begin(tag); - Set globalFunctionDependencies = - source.readMembers().toSet(); + Set globalFunctionDependencies = source + .readMembers() + .toSet(); Set globalClassDependencies = source.readClasses().toSet(); - Set helperFunctionsUsed = - source.readMembers().toSet(); + Set helperFunctionsUsed = source + .readMembers() + .toSet(); Set helperClassesUsed = source.readClasses().toSet(); - Set runtimeTypeUses = - source.readList(() { - RuntimeTypeUseKind kind = source.readEnum(RuntimeTypeUseKind.values); - DartType receiverType = source.readDartType(); - DartType? argumentType = source.readDartTypeOrNull(); - return RuntimeTypeUse(kind, receiverType, argumentType); - }).toSet(); + Set runtimeTypeUses = source.readList(() { + RuntimeTypeUseKind kind = source.readEnum(RuntimeTypeUseKind.values); + DartType receiverType = source.readDartType(); + DartType? argumentType = source.readDartTypeOrNull(); + return RuntimeTypeUse(kind, receiverType, argumentType); + }).toSet(); bool needToInitializeIsolateAffinityTag = source.readBool(); bool needToInitializeDispatchProperty = source.readBool(); bool requiresPreamble = source.readBool(); diff --git a/pkg/compiler/lib/src/js_backend/deferred_holder_expression.dart b/pkg/compiler/lib/src/js_backend/deferred_holder_expression.dart index 789fad8da65..be85c0c2196 100644 --- a/pkg/compiler/lib/src/js_backend/deferred_holder_expression.dart +++ b/pkg/compiler/lib/src/js_backend/deferred_holder_expression.dart @@ -770,8 +770,9 @@ class DeferredHolderExpressionFinalizerImpl for (var resource in holderResources) { // Our default names are either 'MAIN,' 'PART', or '_C'. - var holderName = - resource.isMainFragment ? mainResourceName : 'part${resource.name}'; + var holderName = resource.isMainFragment + ? mainResourceName + : 'part${resource.name}'; holderName = holderName.toUpperCase(); var holder = Holder(holderName); diff --git a/pkg/compiler/lib/src/js_backend/field_analysis.dart b/pkg/compiler/lib/src/js_backend/field_analysis.dart index 3a3cf333041..87e3e72808a 100644 --- a/pkg/compiler/lib/src/js_backend/field_analysis.dart +++ b/pkg/compiler/lib/src/js_backend/field_analysis.dart @@ -348,8 +348,8 @@ class JFieldAnalysis { } ParameterStructure? invokedParameters = closedWorld.annotationsData.hasNoElision(constructor) - ? constructor.parameterStructure - : constructorUsage.invokedParameters; + ? constructor.parameterStructure + : constructorUsage.invokedParameters; Initializer? initializer = data.initializers[constructor]; if (initializer == null) { @@ -561,15 +561,14 @@ class JFieldAnalysis { } } - data = - fieldData[jField] = FieldAnalysisData( - initialValue: value, - isEffectivelyFinal: isEffectivelyFinal, - isElided: isElided, - isEager: isEager, - eagerCreationIndex: creationIndex, - eagerFieldDependenciesForTesting: eagerFieldDependencies, - ); + data = fieldData[jField] = FieldAnalysisData( + initialValue: value, + isEffectivelyFinal: isEffectivelyFinal, + isElided: isElided, + isEager: isEager, + eagerCreationIndex: creationIndex, + eagerFieldDependenciesForTesting: eagerFieldDependencies, + ); } currentFields.remove(kField); @@ -665,8 +664,8 @@ class FieldAnalysisData { bool isLateBackingField = source.readBool(); bool isEager = source.readBool(); int? eagerCreationIndex = source.readIntOrNull(); - List? eagerFieldDependencies = - source.readMembersOrNull(); + List? eagerFieldDependencies = source + .readMembersOrNull(); source.end(tag); return FieldAnalysisData( initialValue: initialValue, diff --git a/pkg/compiler/lib/src/js_backend/frequency_namer.dart b/pkg/compiler/lib/src/js_backend/frequency_namer.dart index 0eef8b2307e..b1a2cd7f47e 100644 --- a/pkg/compiler/lib/src/js_backend/frequency_namer.dart +++ b/pkg/compiler/lib/src/js_backend/frequency_namer.dart @@ -76,8 +76,9 @@ class FrequencyBasedNamer extends Namer return result; } - List usedNames = - tokens.where((TokenName a) => a._rc > 0).toList(); + List usedNames = tokens + .where((TokenName a) => a._rc > 0) + .toList(); usedNames.sort(compareReferenceCount); for (var token in usedNames) { token.finalize(); diff --git a/pkg/compiler/lib/src/js_backend/inferred_data.dart b/pkg/compiler/lib/src/js_backend/inferred_data.dart index f6e26ee08ca..9c26e92916a 100644 --- a/pkg/compiler/lib/src/js_backend/inferred_data.dart +++ b/pkg/compiler/lib/src/js_backend/inferred_data.dart @@ -105,10 +105,12 @@ class InferredDataImpl implements InferredData { Map sideEffects = source.readMemberMap( (MemberEntity member) => SideEffects.readFromDataSource(source), ); - Set elementsThatCannotThrow = - source.readMembers().toSet(); - Set functionsThatMightBePassedToApply = - source.readMembers().toSet(); + Set elementsThatCannotThrow = source + .readMembers() + .toSet(); + Set functionsThatMightBePassedToApply = source + .readMembers() + .toSet(); source.end(tag); return InferredDataImpl( closedWorld, diff --git a/pkg/compiler/lib/src/js_backend/interceptor_data.dart b/pkg/compiler/lib/src/js_backend/interceptor_data.dart index 0f7f272eec6..1dda2568279 100644 --- a/pkg/compiler/lib/src/js_backend/interceptor_data.dart +++ b/pkg/compiler/lib/src/js_backend/interceptor_data.dart @@ -131,8 +131,9 @@ class InterceptorDataImpl implements InterceptorData { interceptedMembers[name] = members; } Set interceptedClasses = source.readClasses().toSet(); - Set classesMixedIntoInterceptedClasses = - source.readClasses().toSet(); + Set classesMixedIntoInterceptedClasses = source + .readClasses() + .toSet(); source.end(tag); return InterceptorDataImpl( nativeData, @@ -192,16 +193,15 @@ class InterceptorDataImpl implements InterceptorData { AbstractValue? mask, JClosedWorld closedWorld, ) { - Set elements = - _interceptedMixinElements[selector.name] ??= - (interceptedMembers[selector.name] - ?.where( - (element) => classesMixedIntoInterceptedClasses.contains( - element.enclosingClass, - ), - ) - .toSet() ?? - const {}); + Set elements = _interceptedMixinElements[selector.name] ??= + (interceptedMembers[selector.name] + ?.where( + (element) => classesMixedIntoInterceptedClasses.contains( + element.enclosingClass, + ), + ) + .toSet() ?? + const {}); if (elements.isEmpty) return false; return elements.any((element) { return selector.applies(element) && @@ -420,8 +420,10 @@ class OneShotInterceptorData { String key = suffixForGetInterceptor(_commonElements, _nativeData, classes); Map interceptors = _oneShotInterceptors[selector] ??= {}; - OneShotInterceptor interceptor = - interceptors[key] ??= OneShotInterceptor(key, selector); + OneShotInterceptor interceptor = interceptors[key] ??= OneShotInterceptor( + key, + selector, + ); interceptor.classes.addAll(classes); registerSpecializedGetInterceptor(classes); return namer.nameForOneShotInterceptor(selector, classes); @@ -434,8 +436,8 @@ class OneShotInterceptorData { classes = _interceptorData.interceptedClasses; } String key = suffixForGetInterceptor(_commonElements, _nativeData, classes); - SpecializedGetInterceptor interceptor = - _specializedGetInterceptors[key] ??= SpecializedGetInterceptor(key); + SpecializedGetInterceptor interceptor = _specializedGetInterceptors[key] ??= + SpecializedGetInterceptor(key); interceptor.classes.addAll(classes); } } diff --git a/pkg/compiler/lib/src/js_backend/minify_namer.dart b/pkg/compiler/lib/src/js_backend/minify_namer.dart index e0b704fe152..769bfc8769d 100644 --- a/pkg/compiler/lib/src/js_backend/minify_namer.dart +++ b/pkg/compiler/lib/src/js_backend/minify_namer.dart @@ -419,20 +419,17 @@ mixin _MinifiedOneShotInterceptorNamer implements Namer { Selector selector, Iterable classes, ) { - final root = - selector.isOperator - ? operatorNameToIdentifier(selector.name) - : privateName(selector.memberName); - String prefix = - selector.isGetter - ? r"$get" - : selector.isSetter - ? r"$set" - : ""; - String callSuffix = - selector.isCall - ? callSuffixForStructure(selector.callStructure).join() - : ""; + final root = selector.isOperator + ? operatorNameToIdentifier(selector.name) + : privateName(selector.memberName); + String prefix = selector.isGetter + ? r"$get" + : selector.isSetter + ? r"$set" + : ""; + String callSuffix = selector.isCall + ? callSuffixForStructure(selector.callStructure).join() + : ""; String suffix = suffixForGetInterceptor( _commonElements, _nativeData, diff --git a/pkg/compiler/lib/src/js_backend/namer.dart b/pkg/compiler/lib/src/js_backend/namer.dart index 103b2209dc7..d3eb2e91e45 100644 --- a/pkg/compiler/lib/src/js_backend/namer.dart +++ b/pkg/compiler/lib/src/js_backend/namer.dart @@ -317,8 +317,10 @@ class Namer extends ModularNamer { // Public names are easy. if (!originalName.isPrivate) return text; - final library = - _elementEnvironment.lookupLibrary(originalName.uri!, required: true)!; + final library = _elementEnvironment.lookupLibrary( + originalName.uri!, + required: true, + )!; // The first library asking for a short private name wins. LibraryEntity owner = shortPrivateNameOwners.putIfAbsent( @@ -704,15 +706,14 @@ class Namer extends ModularNamer { List suffixes = const [], ]) { // Build a string encoding the library name, if the name is private. - String libraryKey = - originalName.isPrivate - ? _generateLibraryKey( - _elementEnvironment.lookupLibrary( - originalName.uri!, - required: true, - )!, - ).toString() - : ''; + String libraryKey = originalName.isPrivate + ? _generateLibraryKey( + _elementEnvironment.lookupLibrary( + originalName.uri!, + required: true, + )!, + ).toString() + : ''; // In the unique key, separate the name parts by '@'. // This avoids clashes since the original names cannot contain that symbol. @@ -1091,8 +1092,9 @@ class Namer extends ModularNamer { @override js_ast.Name staticClosureName(FunctionEntity element) { assert(element.isTopLevel || element.isStatic); - String enclosing = - element.enclosingClass == null ? "" : element.enclosingClass!.name; + String enclosing = element.enclosingClass == null + ? "" + : element.enclosingClass!.name; String library = _proposeNameForLibrary(element.library); String name = replaceNonIdentifierCharacters(element.name!); return _disambiguateInternalGlobal( @@ -2268,11 +2270,10 @@ String suffixForGetInterceptor( return cls.name; } - List names = - classes - .where((cls) => !nativeData.isNativeOrExtendsNative(cls)) - .map(abbreviate) - .toList(); + List names = classes + .where((cls) => !nativeData.isNativeOrExtendsNative(cls)) + .map(abbreviate) + .toList(); // There is one dispatch mechanism for all native classes. if (classes.any((cls) => nativeData.isNativeOrExtendsNative(cls))) { names.add("x"); @@ -2696,13 +2697,12 @@ const List reservedGlobalObjectNames = [ const List reservedGlobalHelperFunctions = ["init"]; -final List userGlobalObjects = - List.from(reservedGlobalObjectNames) - ..remove('C') - ..remove('H') - ..remove('J') - ..remove('P') - ..remove('W'); +final List userGlobalObjects = List.from(reservedGlobalObjectNames) + ..remove('C') + ..remove('H') + ..remove('J') + ..remove('P') + ..remove('W'); final RegExp _identifierStartRE = RegExp(r'[A-Za-z_$]'); final RegExp _nonIdentifierRE = RegExp(r'[^A-Za-z0-9_$]'); diff --git a/pkg/compiler/lib/src/js_backend/native_data.dart b/pkg/compiler/lib/src/js_backend/native_data.dart index a21c8418b53..12016871936 100644 --- a/pkg/compiler/lib/src/js_backend/native_data.dart +++ b/pkg/compiler/lib/src/js_backend/native_data.dart @@ -509,8 +509,9 @@ class NativeDataBuilder { required bool callthrough, }) { final memberType = environment.getFunctionType(member); - final functionType = - callthrough ? memberType.returnType as FunctionType : memberType; + final functionType = callthrough + ? memberType.returnType as FunctionType + : memberType; return dartTypes.isNonNullable(functionType.returnType); } @@ -567,10 +568,9 @@ class NativeDataBuilder { callthrough: member.isGetter && selector.kind == SelectorKind.call, ), ); - data.interopNullChecks[selector] = - canCheckInCallee - ? InteropNullCheckKind.calleeCheck - : InteropNullCheckKind.callerCheck; + data.interopNullChecks[selector] = canCheckInCallee + ? InteropNullCheckKind.calleeCheck + : InteropNullCheckKind.callerCheck; }); } diff --git a/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart b/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart index cb641d59e0b..b578bba38a2 100644 --- a/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart +++ b/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart @@ -176,16 +176,19 @@ class NoSuchMethodData { /// Deserializes a [NoSuchMethodData] object from [source]. factory NoSuchMethodData.readFromDataSource(DataSourceReader source) { source.begin(tag); - Set throwingImpls = - source.readMembers().toSet(); - Set otherImpls = - source.readMembers().toSet(); - Set forwardingSyntaxImpls = - source.readMembers().toSet(); - List complexNoReturnImpls = - source.readMembers(); - List complexReturningImpls = - source.readMembers(); + Set throwingImpls = source + .readMembers() + .toSet(); + Set otherImpls = source + .readMembers() + .toSet(); + Set forwardingSyntaxImpls = source + .readMembers() + .toSet(); + List complexNoReturnImpls = source + .readMembers(); + List complexReturningImpls = source + .readMembers(); source.end(tag); return NoSuchMethodData(throwingImpls, otherImpls, forwardingSyntaxImpls) .._complexNoReturnImpls.addAll(complexNoReturnImpls) diff --git a/pkg/compiler/lib/src/js_backend/runtime_types.dart b/pkg/compiler/lib/src/js_backend/runtime_types.dart index a5a743c74ba..40034ec6e06 100644 --- a/pkg/compiler/lib/src/js_backend/runtime_types.dart +++ b/pkg/compiler/lib/src/js_backend/runtime_types.dart @@ -94,14 +94,13 @@ class TrivialRuntimeTypesChecksBuilder implements RuntimeTypesChecksBuilder { in _closedWorld.classHierarchy .getClassSet(_closedWorld.commonElements.objectClass) .subtypes()) { - ClassUse classUse = - ClassUse() - ..directInstance = true - ..checkedInstance = true - ..typeArgument = true - ..checkedTypeArgument = true - ..typeLiteral = true - ..functionType = _computeFunctionType(_elementEnvironment, cls); + ClassUse classUse = ClassUse() + ..directInstance = true + ..checkedInstance = true + ..typeArgument = true + ..checkedTypeArgument = true + ..typeLiteral = true + ..functionType = _computeFunctionType(_elementEnvironment, cls); classUseMap[cls] = classUse; } TypeChecks typeChecks = _substitutions._computeChecks(classUseMap); @@ -263,8 +262,9 @@ mixin RuntimeTypesSubstitutionsMixin implements RuntimeTypesSubstitutions { ); // The checks for [checkedClass] inherited for [superClass]. - TypeCheck? checkFromSuperClass = - superChecks != null ? superChecks[checkedClass] : null; + TypeCheck? checkFromSuperClass = superChecks != null + ? superChecks[checkedClass] + : null; // Whether [cls] need an explicit $isX property for [checkedClass]. // @@ -297,8 +297,10 @@ mixin RuntimeTypesSubstitutionsMixin implements RuntimeTypesSubstitutions { } else { // We need a non-trivial substitution function for // [checkedClass]. - Substitution substitution = - computeSubstitution(cls, checkedClass)!; + Substitution substitution = computeSubstitution( + cls, + checkedClass, + )!; checks.add( TypeCheck(checkedClass, substitution, needsIs: false), ); @@ -321,8 +323,10 @@ mixin RuntimeTypesSubstitutionsMixin implements RuntimeTypesSubstitutions { } else { // We need a non-trivial substitution function for // [checkedClass]. - Substitution substitution = - computeSubstitution(cls, checkedClass)!; + Substitution substitution = computeSubstitution( + cls, + checkedClass, + )!; checks.add( TypeCheck(checkedClass, substitution, needsIs: needsIs), ); @@ -756,8 +760,8 @@ class RuntimeTypesImpl .getParameterCheckPolicy(method) .isEmitted) { if (_rtiNeed.methodNeedsTypeArguments(method)) { - for (TypeVariableType typeVariable in _elementEnvironment - .getFunctionTypeVariables(method)) { + for (TypeVariableType typeVariable + in _elementEnvironment.getFunctionTypeVariables(method)) { DartType bound = _elementEnvironment.getTypeVariableBound( typeVariable.element, ); diff --git a/pkg/compiler/lib/src/js_backend/runtime_types_new.dart b/pkg/compiler/lib/src/js_backend/runtime_types_new.dart index 6b73c237058..e0e82fd4995 100644 --- a/pkg/compiler/lib/src/js_backend/runtime_types_new.dart +++ b/pkg/compiler/lib/src/js_backend/runtime_types_new.dart @@ -693,10 +693,9 @@ int? indexTypeVariable( // index, even though in the general case it is not at a specific index. ClassHierarchy classHierarchy = world.classHierarchy; - var test = - mustCheckAllSubtypes(world, cls) - ? classHierarchy.anyStrictSubtypeOf - : classHierarchy.anyStrictSubclassOf; + var test = mustCheckAllSubtypes(world, cls) + ? classHierarchy.anyStrictSubtypeOf + : classHierarchy.anyStrictSubclassOf; if (test(cls, (ClassEntity subclass) { return !rtiSubstitutions.isTrivialSubstitution(subclass, cls); })) { diff --git a/pkg/compiler/lib/src/js_backend/runtime_types_resolution.dart b/pkg/compiler/lib/src/js_backend/runtime_types_resolution.dart index 994f2b50495..02c1a983215 100644 --- a/pkg/compiler/lib/src/js_backend/runtime_types_resolution.dart +++ b/pkg/compiler/lib/src/js_backend/runtime_types_resolution.dart @@ -885,16 +885,21 @@ class RuntimeTypesNeedImpl implements RuntimeTypesNeed { ElementEnvironment elementEnvironment, ) { source.begin(tag); - Set classesNeedingTypeArguments = - source.readClasses().toSet(); - Set methodsNeedingSignature = - source.readMembers().toSet(); - Set methodsNeedingTypeArguments = - source.readMembers().toSet(); - Set selectorsNeedingTypeArguments = - source.readList(() => Selector.readFromDataSource(source)).toSet(); - Set instantiationsNeedingTypeArguments = - source.readList(source.readInt).toSet(); + Set classesNeedingTypeArguments = source + .readClasses() + .toSet(); + Set methodsNeedingSignature = source + .readMembers() + .toSet(); + Set methodsNeedingTypeArguments = source + .readMembers() + .toSet(); + Set selectorsNeedingTypeArguments = source + .readList(() => Selector.readFromDataSource(source)) + .toSet(); + Set instantiationsNeedingTypeArguments = source + .readList(source.readInt) + .toSet(); source.end(tag); return RuntimeTypesNeedImpl( elementEnvironment, @@ -1130,8 +1135,9 @@ class RuntimeTypesNeedBuilderImpl implements RuntimeTypesNeedBuilder { } Set localFunctions = closedWorld.localFunctions.toSet(); - Set closurizedMembers = - closedWorld.closurizedMembersWithFreeTypeVariables.toSet(); + Set closurizedMembers = closedWorld + .closurizedMembersWithFreeTypeVariables + .toSet(); // Check local functions and closurized members. void checkClosures({required DartType potentialSubtypeOf}) { @@ -1389,10 +1395,9 @@ class RuntimeTypesNeedBuilderImpl implements RuntimeTypesNeedBuilder { Set allClassesNeedingRuntimeType; if (neededOnAll) { neededOnFunctions = true; - allClassesNeedingRuntimeType = - closedWorld.classHierarchy - .subclassesOf(commonElements.objectClass) - .toSet(); + allClassesNeedingRuntimeType = closedWorld.classHierarchy + .subclassesOf(commonElements.objectClass) + .toSet(); } else { allClassesNeedingRuntimeType = {}; // TODO(johnniwinther): Support this operation directly in diff --git a/pkg/compiler/lib/src/js_backend/string_reference.dart b/pkg/compiler/lib/src/js_backend/string_reference.dart index 3159897254a..800c13ac6f9 100644 --- a/pkg/compiler/lib/src/js_backend/string_reference.dart +++ b/pkg/compiler/lib/src/js_backend/string_reference.dart @@ -266,8 +266,9 @@ class StringReferenceFinalizerImpl implements StringReferenceFinalizer { // Called from collector visitor. void registerStringReference(StringReference node) { StringConstantValue constant = node.constant; - _ReferenceSet refs = - _referencesByString[constant] ??= _ReferenceSet(constant); + _ReferenceSet refs = _referencesByString[constant] ??= _ReferenceSet( + constant, + ); refs.count++; refs._references.add(node); } @@ -290,8 +291,10 @@ class StringReferenceFinalizerImpl implements StringReferenceFinalizer { } } - List<_ReferenceSet> referenceSetsUsingProperties = - _referencesByString.values.where((ref) => !ref.generateAtUse).toList(); + List<_ReferenceSet> referenceSetsUsingProperties = _referencesByString + .values + .where((ref) => !ref.generateAtUse) + .toList(); // Sort by string (which is unique and stable) so that similar strings are // grouped together. @@ -363,14 +366,14 @@ class StringReferenceFinalizerImpl implements StringReferenceFinalizer { // Step 2. Sort by frequency to arrange common entries have shorter property // names. - List<_ReferenceSet> referencesByFrequency = - referencesInTable.toList()..sort((a, b) { - assert(a.name != b.name); - int r = b.count.compareTo(a.count); // Decreasing frequency. - if (r != 0) return r; - // Tie-break with raw string. - return _ReferenceSet.compareByString(a, b); - }); + List<_ReferenceSet> referencesByFrequency = referencesInTable.toList() + ..sort((a, b) { + assert(a.name != b.name); + int r = b.count.compareTo(a.count); // Decreasing frequency. + if (r != 0) return r; + // Tie-break with raw string. + return _ReferenceSet.compareByString(a, b); + }); for (final referenceSet in referencesByFrequency) { // TODO(sra): Assess the dispersal of this hash function in the diff --git a/pkg/compiler/lib/src/js_backend/type_reference.dart b/pkg/compiler/lib/src/js_backend/type_reference.dart index 7ff774076c6..f923eeb977a 100644 --- a/pkg/compiler/lib/src/js_backend/type_reference.dart +++ b/pkg/compiler/lib/src/js_backend/type_reference.dart @@ -308,8 +308,10 @@ class TypeReferenceFinalizerImpl implements TypeReferenceFinalizer { } } - List<_ReferenceSet> referenceSetsUsingProperties = - _referencesByRecipe.values.where((ref) => !ref.generateAtUse).toList(); + List<_ReferenceSet> referenceSetsUsingProperties = _referencesByRecipe + .values + .where((ref) => !ref.generateAtUse) + .toList(); // Sort by name (which is unique and mostly stable) so that similar recipes // are grouped together. @@ -320,8 +322,9 @@ class TypeReferenceFinalizerImpl implements TypeReferenceFinalizer { // Doing so saves 2-3 bytes per entry, but with an overhead of 30+ bytes for // the IIFE. So it is smaller to use the IIFE only for over 10 or so types. const minUseIIFE = 10; - final helperLocal = - referenceSetsUsingProperties.length < minUseIIFE ? null : 'findType'; + final helperLocal = referenceSetsUsingProperties.length < minUseIIFE + ? null + : 'findType'; List properties = []; for (_ReferenceSet referenceSet in referenceSetsUsingProperties) { @@ -431,15 +434,15 @@ class TypeReferenceFinalizerImpl implements TypeReferenceFinalizer { // Step 2. Sort by frequency to arrange common entries have shorter property // names. - List<_ReferenceSet> referencesByFrequency = - referencesInTable.toList()..sort((a, b) { - assert(a.name != b.name); - int r = b.count.compareTo(a.count); // Decreasing frequency. - if (r != 0) return r; - return a.name!.compareTo( - b.name!, - ); // Tie-break with characteristic name. - }); + List<_ReferenceSet> referencesByFrequency = referencesInTable.toList() + ..sort((a, b) { + assert(a.name != b.name); + int r = b.count.compareTo(a.count); // Decreasing frequency. + if (r != 0) return r; + return a.name!.compareTo( + b.name!, + ); // Tie-break with characteristic name. + }); for (var referenceSet in referencesByFrequency) { referenceSet.hash = _hashCharacteristicString(referenceSet.name!); diff --git a/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart b/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart index c696ccb44c6..b43d95e9b26 100644 --- a/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart +++ b/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart @@ -180,11 +180,10 @@ class ClassStubGenerator { List.generate(selector.argumentCount, (i) => '\$$i') + List.generate(selector.typeArgumentCount, (i) => '\$T${i + 1}'); - List argNames = - selector.callStructure - .getOrderedNamedArguments() - .map((String name) => js.string(name)) - .toList(); + List argNames = selector.callStructure + .getOrderedNamedArguments() + .map((String name) => js.string(name)) + .toList(); js_ast.Name methodName = _namer.asName(selector.invocationMirrorMemberName); js_ast.Name internalName = _namer.invocationMirrorInternalName(selector); diff --git a/pkg/compiler/lib/src/js_emitter/instantiation_stub_generator.dart b/pkg/compiler/lib/src/js_emitter/instantiation_stub_generator.dart index 78003e5db18..53d22231967 100644 --- a/pkg/compiler/lib/src/js_emitter/instantiation_stub_generator.dart +++ b/pkg/compiler/lib/src/js_emitter/instantiation_stub_generator.dart @@ -155,11 +155,10 @@ class InstantiationStubGenerator { FunctionEntity? member, ) { // 1. Find the number of type parameters in [instantiationClass]. - int typeArgumentCount = - _closedWorld.dartTypes - .getThisType(instantiationClass) - .typeArguments - .length; + int typeArgumentCount = _closedWorld.dartTypes + .getThisType(instantiationClass) + .typeArguments + .length; assert(typeArgumentCount > 0); // 2. Find the function field access path. diff --git a/pkg/compiler/lib/src/js_emitter/metadata_collector.dart b/pkg/compiler/lib/src/js_emitter/metadata_collector.dart index b61e5dcee92..bb5bcb39172 100644 --- a/pkg/compiler/lib/src/js_emitter/metadata_collector.dart +++ b/pkg/compiler/lib/src/js_emitter/metadata_collector.dart @@ -154,10 +154,9 @@ class MetadataCollector implements js_ast.TokenFinalizer { js_ast.Expression _addTypeInOutputUnit(DartType type, OutputUnit outputUnit) { final typeMap = _typesMap[outputUnit] ??= {}; - final metadataEntryList = - (typeMap[type] ??= [ - BoundMetadataEntry(_computeTypeRepresentation(type)), - ]); + final metadataEntryList = (typeMap[type] ??= [ + BoundMetadataEntry(_computeTypeRepresentation(type)), + ]); return metadataEntryList.single; } diff --git a/pkg/compiler/lib/src/js_emitter/program_builder/collector.dart b/pkg/compiler/lib/src/js_emitter/program_builder/collector.dart index 1f7f4c8c510..f2279ded2b8 100644 --- a/pkg/compiler/lib/src/js_emitter/program_builder/collector.dart +++ b/pkg/compiler/lib/src/js_emitter/program_builder/collector.dart @@ -138,8 +138,9 @@ class Collector { /// Compute all the classes and typedefs that must be emitted. void computeNeededDeclarations() { - Set backendTypeHelpers = - getBackendTypeHelpers(_commonElements).toSet(); + Set backendTypeHelpers = getBackendTypeHelpers( + _commonElements, + ).toSet(); // Compute needed classes. Set instantiatedClasses = @@ -163,11 +164,10 @@ class Collector { addClassesWithSuperclasses(instantiatedClasses); // 2. Add all classes used as mixins. - Set mixinClasses = - neededClasses - .map(_elementEnvironment.getEffectiveMixinClass) - .whereType() - .toSet(); + Set mixinClasses = neededClasses + .map(_elementEnvironment.getEffectiveMixinClass) + .whereType() + .toSet(); neededClasses.addAll(mixinClasses); // 3. Add classes only needed for their constructors. diff --git a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart index 33ca725226c..95b283ddc8c 100644 --- a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart +++ b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart @@ -234,13 +234,12 @@ class ProgramBuilder { } }); - List nativeClasses = - collector.nativeClassesAndSubclasses - .map((ClassEntity classElement) => _classes[classElement]!) - .toList(); + List nativeClasses = collector.nativeClassesAndSubclasses + .map((ClassEntity classElement) => _classes[classElement]!) + .toList(); - Set interceptorClassesNeededByConstants = - collector.computeInterceptorsReferencedFromConstants(); + Set interceptorClassesNeededByConstants = collector + .computeInterceptorsReferencedFromConstants(); _unneededNativeClasses = _task.nativeEmitter.prepareNativeClasses( nativeClasses, @@ -509,13 +508,13 @@ class ProgramBuilder { if (stubNames.add(stubName.key)) { final code = _options.interopNullAssertions && - _nativeData.interopNullChecks[selector] == - InteropNullCheckKind.calleeCheck - ? js.js('function(obj) { return #(obj.#) }', [ - interopNullAssert, - jsName, - ]) - : js.js('function(obj) { return obj.# }', [jsName]); + _nativeData.interopNullChecks[selector] == + InteropNullCheckKind.calleeCheck + ? js.js('function(obj) { return #(obj.#) }', [ + interopNullAssert, + jsName, + ]) + : js.js('function(obj) { return obj.# }', [jsName]); interceptorClass!.callStubs.add( _buildStubMethod(stubName, code, element: member), ); @@ -593,16 +592,16 @@ class ProgramBuilder { // would. final code = _options.interopNullAssertions && - _nativeData.interopNullChecks[selector] == - InteropNullCheckKind.calleeCheck - ? js.js( - 'function(receiver, #) { return #(receiver.#(#)) }', - [parameters, interopNullAssert, jsName, parameters], - ) - : js.js( - 'function(receiver, #) { return receiver.#(#) }', - [parameters, jsName, parameters], - ); + _nativeData.interopNullChecks[selector] == + InteropNullCheckKind.calleeCheck + ? js.js( + 'function(receiver, #) { return #(receiver.#(#)) }', + [parameters, interopNullAssert, jsName, parameters], + ) + : js.js( + 'function(receiver, #) { return receiver.#(#) }', + [parameters, jsName, parameters], + ); interceptorClass!.callStubs.add( _buildStubMethod(stubName, code, element: member), ); @@ -625,14 +624,13 @@ class ProgramBuilder { ) { String uri = library.canonicalUri.toString(); - List statics = - memberElements - // We omit static stubs here because we use the function bodies directly - // when we install the tear offs. - .where((e) => e is! FieldEntity && e is! JParameterStub) - .cast() - .map(_buildStaticMethod) - .toList(); + List statics = memberElements + // We omit static stubs here because we use the function bodies directly + // when we install the tear offs. + .where((e) => e is! FieldEntity && e is! JParameterStub) + .cast() + .map(_buildStaticMethod) + .toList(); if (library == _commonElements.interceptorsLibrary) { statics.addAll(_generateGetInterceptorMethods()); @@ -646,13 +644,11 @@ class ProgramBuilder { ) .toList(growable: false); - List classTypeData = - classTypeElements - .map( - (ClassEntity classTypeElement) => - _classTypeData[classTypeElement]!, - ) - .toList(); + List classTypeData = classTypeElements + .map( + (ClassEntity classTypeElement) => _classTypeData[classTypeElement]!, + ) + .toList(); classTypeData.addAll(classes.map((Class cls) => cls.typeData).toList()); return Library(library, uri, statics, classes, classTypeData); @@ -741,8 +737,8 @@ class ProgramBuilder { if (_backendUsage.isNoSuchMethodUsed && cls == _commonElements.objectClass) { - Map selectors = - classStubGenerator.computeSelectorsForNsmHandlers(); + Map selectors = classStubGenerator + .computeSelectorsForNsmHandlers(); selectors.forEach((js.Name name, Selector selector) { // If the program contains `const Symbol` names we have to retain them. String selectorName = selector.name; @@ -794,25 +790,20 @@ class ProgramBuilder { } } bool isInterceptedClass = _interceptorData.isInterceptedClass(cls); - List instanceFields = - onlyForConstructorOrRti - ? const [] - : _buildFields( - cls: cls, - isHolderInterceptedClass: isInterceptedClass, - ); + List instanceFields = onlyForConstructorOrRti + ? const [] + : _buildFields(cls: cls, isHolderInterceptedClass: isInterceptedClass); - List gettersSetters = - onlyForConstructorOrRti - ? const [] - : [ - for (Field field in instanceFields) - if (field.needsGetter) - classStubGenerator.generateGetter(field) as StubMethod, - for (Field field in instanceFields) - if (field.needsUncheckedSetter) - classStubGenerator.generateSetter(field) as StubMethod, - ]; + List gettersSetters = onlyForConstructorOrRti + ? const [] + : [ + for (Field field in instanceFields) + if (field.needsGetter) + classStubGenerator.generateGetter(field) as StubMethod, + for (Field field in instanceFields) + if (field.needsUncheckedSetter) + classStubGenerator.generateSetter(field) as StubMethod, + ]; TypeTestProperties typeTests = runtimeTypeGenerator.generateIsTests( cls, @@ -915,18 +906,17 @@ class ProgramBuilder { ); void associateNamedTypeVariables() { - for (TypeVariableType typeVariable in _codegenWorld.namedTypeVariables - .union(_lateNamedTypeVariables)) { + for (TypeVariableType typeVariable + in _codegenWorld.namedTypeVariables.union(_lateNamedTypeVariables)) { final declaration = typeVariable.element.typeDeclaration as ClassEntity; Iterable subtypes = new_rti.mustCheckAllSubtypes(_closedWorld, declaration) - ? _classHierarchy.subtypesOf(declaration) - : _classHierarchy.subclassesOf(declaration); + ? _classHierarchy.subtypesOf(declaration) + : _classHierarchy.subclassesOf(declaration); for (ClassEntity entity in subtypes) { - ClassTypeData classTypeData = - _nativeData.isJsInteropClass(entity) - ? _buildClassTypeData(_jsInteropInterceptor) - : _buildClassTypeData(entity); + ClassTypeData classTypeData = _nativeData.isJsInteropClass(entity) + ? _buildClassTypeData(_jsInteropInterceptor) + : _buildClassTypeData(entity); classTypeData.namedTypeVariables.add(typeVariable); } } @@ -989,10 +979,9 @@ class ProgramBuilder { bool canBeApplied = _methodCanBeApplied(element); - final aliasName = - _codegenWorld.isAliasedSuperMember(element) - ? _namer.aliasedSuperMemberPropertyName(element) - : null; + final aliasName = _codegenWorld.isAliasedSuperMember(element) + ? _namer.aliasedSuperMemberPropertyName(element) + : null; if (isNotApplyTarget) { canTearOff = false; @@ -1365,13 +1354,13 @@ class ProgramBuilder { final stubMethods = _codegenWorld .getParameterStubs(element) .map((stub) { - final name = - element.isStatic ? null : _namer.instanceMethodName(stub); + final name = element.isStatic + ? null + : _namer.instanceMethodName(stub); final callSelector = stub.callSelector; - final callName = - (callSelector != null) - ? _namer.invocationName(callSelector) - : null; + final callName = (callSelector != null) + ? _namer.invocationName(callSelector) + : null; final stubCode = _generatedCode[stub]!; return ParameterStubMethod( name, diff --git a/pkg/compiler/lib/src/js_emitter/program_builder/registry.dart b/pkg/compiler/lib/src/js_emitter/program_builder/registry.dart index b283857c5a7..2ab8fe6f5f0 100644 --- a/pkg/compiler/lib/src/js_emitter/program_builder/registry.dart +++ b/pkg/compiler/lib/src/js_emitter/program_builder/registry.dart @@ -105,10 +105,9 @@ class Registry { LibrariesMap _mapUnitToLibrariesMap(OutputUnit targetUnit) { if (targetUnit == _lastOutputUnit) return _lastLibrariesMap; - final result = - (targetUnit == _mainOutputUnit) - ? mainLibrariesMap - : _deferredLibrariesMap[targetUnit]!; + final result = (targetUnit == _mainOutputUnit) + ? mainLibrariesMap + : _deferredLibrariesMap[targetUnit]!; _lastOutputUnit = targetUnit; _lastLibrariesMap = result; diff --git a/pkg/compiler/lib/src/js_emitter/resource_info_emitter.dart b/pkg/compiler/lib/src/js_emitter/resource_info_emitter.dart index 6db540b3584..fc568b710d1 100644 --- a/pkg/compiler/lib/src/js_emitter/resource_info_emitter.dart +++ b/pkg/compiler/lib/src/js_emitter/resource_info_emitter.dart @@ -110,8 +110,8 @@ class ResourceInfoCollector { '_comment': r'Resources referenced by annotated resource identifers', 'AppTag': 'TBD', 'environment': environment, - 'identifiers': - _identifierMap.values.toList()..sort(_ResourceIdentifierInfo.compare), + 'identifiers': _identifierMap.values.toList() + ..sort(_ResourceIdentifierInfo.compare), }; return json; } @@ -144,8 +144,8 @@ class _ResourceIdentifierInfo { } Map toJson() { - final files = - _files.entries.toList()..sort((a, b) => a.key.compareTo(b.key)); + final files = _files.entries.toList() + ..sort((a, b) => a.key.compareTo(b.key)); return { "name": _key.name, "uri": _key.uri.toString(), diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart index 80a822d9c19..198795dccf0 100644 --- a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart +++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart @@ -33,7 +33,8 @@ part of 'model_emitter.dart'; // JavaScript variables (like `Array`) we are free to chose whatever variable // names we want. Furthermore, the pretty-printer minifies local variables, thus // reducing their size. -const String _mainBoilerplate = ''' +const String _mainBoilerplate = + ''' (function dartProgram() { if (#startupMetrics) { @@ -893,8 +894,9 @@ class FragmentEmitter { js.quoteName(key), value as js.Fun, ); - final Entity holderKey = - method is StaticStubMethod ? method.library : method.element!; + final Entity holderKey = method is StaticStubMethod + ? method.library + : method.element!; assert( method is! StaticStubMethod || method.library == _commonElements.interceptorsLibrary, @@ -1099,10 +1101,9 @@ class FragmentEmitter { js.Expression name, js.Expression code, ) { - js.Property property = - code is js.Fun - ? js.MethodDefinition(name, code) - : js.Property(name, code); + js.Property property = code is js.Fun + ? js.MethodDefinition(name, code) + : js.Property(name, code); registerEntityAst(method.element, property); properties.add(property); }); @@ -1185,10 +1186,9 @@ class FragmentEmitter { // Avoid adding the metadata if a superclass has the same metadata. if (!method.inheritsApplyMetadata) { - final applyName = - method.applyIndex == 0 - ? method.name! - : method.parameterStubs[method.applyIndex - 1].name!; + final applyName = method.applyIndex == 0 + ? method.name! + : method.parameterStubs[method.applyIndex - 1].name!; properties[js.string(_namer.fixedNames.callCatchAllName)] = js .quoteName(applyName); properties[js.string(_namer.fixedNames.requiredParameterField)] = js @@ -1259,8 +1259,9 @@ class FragmentEmitter { } subclasses.forEach((superclass, list) { - js.Expression superclassReference = - (superclass == null) ? js.LiteralNull() : classReference(superclass); + js.Expression superclassReference = (superclass == null) + ? js.LiteralNull() + : classReference(superclass); if (list.length == 1) { Class cls = list.single; var statement = js.js.statement('#(#, #)', [ @@ -1621,8 +1622,9 @@ class FragmentEmitter { } } for (Class cls in library.classes) { - var methods = - cls.methods.where((m) => (m as DartMethod).needsTearOff).toList(); + var methods = cls.methods + .where((m) => (m as DartMethod).needsTearOff) + .toList(); js.Expression container = js.js("#.prototype", classReference(cls)); js.Expression? reference = container; if (methods.length > 1) { @@ -1750,10 +1752,9 @@ class FragmentEmitter { List statements = []; LocalAliases locals = LocalAliases(); for (StaticField field in fields) { - String helper = - field.isFinal - ? locals.find('_lazyFinal', 'hunkHelpers.lazyFinal') - : locals.find('_lazy', 'hunkHelpers.lazy'); + String helper = field.isFinal + ? locals.find('_lazyFinal', 'hunkHelpers.lazyFinal') + : locals.find('_lazy', 'hunkHelpers.lazy'); js.Expression staticFieldCode = field.code; if (staticFieldCode is js.Fun) { // An arrow function `() => { ...; return e }` is smaller that @@ -2147,14 +2148,13 @@ class FragmentEmitter { ruleset.addRedirection(element, legacyJsObjectClass); } else { Iterable checks = typeData.classChecks.checks; - Iterable supertypes = - isInterop - ? checks.map( - (check) => _elementEnvironment.getJsInteropType(check.cls), - ) - : checks.map( - (check) => _dartTypes.asInstanceOf(targetType, check.cls)!, - ); + Iterable supertypes = isInterop + ? checks.map( + (check) => _elementEnvironment.getJsInteropType(check.cls), + ) + : checks.map( + (check) => _dartTypes.asInstanceOf(targetType, check.cls)!, + ); Map typeVariables = {}; Set namedTypeVariables = typeData.namedTypeVariables; @@ -2164,10 +2164,9 @@ class FragmentEmitter { for (TypeVariableType typeVariable in typeData.namedTypeVariables) { TypeVariableEntity element = typeVariable.element; final typeDeclaration = element.typeDeclaration as ClassEntity; - final supertype = - isInterop - ? _elementEnvironment.getJsInteropType(typeDeclaration) - : _dartTypes.asInstanceOf(targetType, typeDeclaration)!; + final supertype = isInterop + ? _elementEnvironment.getJsInteropType(typeDeclaration) + : _dartTypes.asInstanceOf(targetType, typeDeclaration)!; List supertypeArguments = supertype.typeArguments; typeVariables[typeVariable] = supertypeArguments[element.index]; } diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_merger.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_merger.dart index e79540e071c..0de8d67b420 100644 --- a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_merger.dart +++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_merger.dart @@ -281,10 +281,9 @@ class PreFragment { Map outputUnitMap, Map codeFragmentMap, ) { - List codeFragments = - shouldInterleave - ? [interleaveEmittedOutputUnits(program)] - : bundleEmittedOutputUnits(program); + List codeFragments = shouldInterleave + ? [interleaveEmittedOutputUnits(program)] + : bundleEmittedOutputUnits(program); finalizedFragment = FinalizedFragment(outputFileName, codeFragments); for (var codeFragment in codeFragments) { codeFragmentMap[codeFragment] = finalizedFragment; @@ -698,19 +697,18 @@ class FragmentMerger { }, ); - List partFileNames = - fragments - .map( - (fragment) => deferredPartFileName( - _options, - fragment.canonicalOutputUnit.name, - ), - ) - .toList(); + List partFileNames = fragments + .map( + (fragment) => deferredPartFileName( + _options, + fragment.canonicalOutputUnit.name, + ), + ) + .toList(); (libraryMap['imports'] as Map>)[importDeferName] = partFileNames; - (libraryMap['importPrefixToLoadId'] as Map)[import - .name!] = + (libraryMap['importPrefixToLoadId'] + as Map)[import.name!] = importDeferName; } return mapping; diff --git a/pkg/compiler/lib/src/js_model/closure.dart b/pkg/compiler/lib/src/js_model/closure.dart index 076ccb3e949..bf30c658130 100644 --- a/pkg/compiler/lib/src/js_model/closure.dart +++ b/pkg/compiler/lib/src/js_model/closure.dart @@ -478,12 +478,12 @@ class ClosureDataBuilder { KernelCapturedScope signatureCapturedScope = KernelCapturedScope.forSignature(capturedScope); _updateScopeBasedOnRtiNeed(signatureCapturedScope, rtiNeed, member); - _capturedScopeForSignatureMap[closureClassInfo - .signatureMethod!] = JsCapturedScope.from( - {}, - signatureCapturedScope, - member.enclosingClass, - ); + _capturedScopeForSignatureMap[closureClassInfo.signatureMethod!] = + JsCapturedScope.from( + {}, + signatureCapturedScope, + member.enclosingClass, + ); } } callMethods.add(closureClassInfo.callMethod!); @@ -633,8 +633,8 @@ class JsScopeInfo extends ScopeInfo { factory JsScopeInfo.readFromDataSource(DataSourceReader source) { source.begin(tag); - Iterable localsUsedInTryOrSync = - source.readTreeNodes(); + Iterable localsUsedInTryOrSync = source + .readTreeNodes(); Local? thisLocal = source.readLocalOrNull(); Map boxedVariables = source .readTreeNodeMap( @@ -679,8 +679,9 @@ class JsCapturedScope extends JsScopeInfo implements CapturedScope { super.boxedVariables, super.capturedScope, super.enclosingClass, - ) : contextBox = - boxedVariables.isNotEmpty ? boxedVariables.values.first.box : null, + ) : contextBox = boxedVariables.isNotEmpty + ? boxedVariables.values.first.box + : null, super.from(); @override @@ -688,8 +689,8 @@ class JsCapturedScope extends JsScopeInfo implements CapturedScope { factory JsCapturedScope.readFromDataSource(DataSourceReader source) { source.begin(tag); - Iterable localsUsedInTryOrSync = - source.readTreeNodes(); + Iterable localsUsedInTryOrSync = source + .readTreeNodes(); Local? thisLocal = source.readLocalOrNull(); Map boxedVariables = source .readTreeNodeMap( @@ -744,16 +745,16 @@ class JsCapturedLoopScope extends JsCapturedScope implements CapturedLoopScope { factory JsCapturedLoopScope.readFromDataSource(DataSourceReader source) { source.begin(tag); - Iterable localsUsedInTryOrSync = - source.readTreeNodes(); + Iterable localsUsedInTryOrSync = source + .readTreeNodes(); Local? thisLocal = source.readLocalOrNull(); Map boxedVariables = source .readTreeNodeMap( () => source.readMember() as JContextField, ); Local? context = source.readLocalOrNull(); - List boxedLoopVariables = - source.readTreeNodes(); + List boxedLoopVariables = source + .readTreeNodes(); source.end(tag); return JsCapturedLoopScope.internal( localsUsedInTryOrSync, @@ -844,8 +845,8 @@ class JsClosureClassInfo extends JsScopeInfo factory JsClosureClassInfo.readFromDataSource(DataSourceReader source) { source.begin(tag); - Iterable localsUsedInTryOrSync = - source.readTreeNodes(); + Iterable localsUsedInTryOrSync = source + .readTreeNodes(); Local? thisLocal = source.readLocalOrNull(); Map boxedVariables = source .readTreeNodeMap( diff --git a/pkg/compiler/lib/src/js_model/element_map.dart b/pkg/compiler/lib/src/js_model/element_map.dart index c0fd2927fdf..84b29c54bb7 100644 --- a/pkg/compiler/lib/src/js_model/element_map.dart +++ b/pkg/compiler/lib/src/js_model/element_map.dart @@ -468,10 +468,9 @@ class SpecialMemberDefinition implements MemberDefinition { : _node = Deferrable.eager(node); SpecialMemberDefinition.from(MemberDefinition baseMember, this.kind) - : _node = - baseMember is ClosureMemberDefinition - ? baseMember._node - : Deferrable.eager(baseMember.node as ir.TreeNode); + : _node = baseMember is ClosureMemberDefinition + ? baseMember._node + : Deferrable.eager(baseMember.node as ir.TreeNode); SpecialMemberDefinition._deserialized(this._node, this.kind); diff --git a/pkg/compiler/lib/src/js_model/element_map_impl.dart b/pkg/compiler/lib/src/js_model/element_map_impl.dart index 485919c14ec..a79265515be 100644 --- a/pkg/compiler/lib/src/js_model/element_map_impl.dart +++ b/pkg/compiler/lib/src/js_model/element_map_impl.dart @@ -615,8 +615,10 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap { if (data is JClassDataImpl && data.thisType == null) { ir.Class node = data.cls; if (node.typeParameters.isEmpty) { - data.thisType = - data.rawType = types.interfaceType(cls, const []); + data.thisType = data.rawType = types.interfaceType( + cls, + const [], + ); } else { data.thisType = types.interfaceType( cls, @@ -696,11 +698,10 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap { Set canonicalSupertypes = {}; InterfaceType processSupertype(ir.Supertype supertypeNode) { - supertypeNode = - classHierarchy.getClassAsInstanceOf( - node, - supertypeNode.classNode, - )!; + supertypeNode = classHierarchy.getClassAsInstanceOf( + node, + supertypeNode.classNode, + )!; InterfaceType supertype = _typeConverter.visitSupertype( supertypeNode, ); @@ -759,10 +760,8 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap { cls, nativeData, ); - InterfaceType defaultSupertype = - data.supertype = _elementEnvironment.getRawType( - defaultSuperclass, - ); + InterfaceType defaultSupertype = data.supertype = _elementEnvironment + .getRawType(defaultSuperclass); assert( defaultSupertype.typeArguments.isEmpty, "Generic default supertypes are not supported", @@ -1305,8 +1304,8 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap { // library. // TODO(johnniwinther): Cache more results to avoid redundant lookups? cachedMayLookupInMain ??= - // Tests permit lookup outside of dart: libraries. - allowedNativeTest(elementEnvironment.mainLibrary!.canonicalUri); + // Tests permit lookup outside of dart: libraries. + allowedNativeTest(elementEnvironment.mainLibrary!.canonicalUri); DartType? type; if (cachedMayLookupInMain!) { type ??= findInLibrary(elementEnvironment.mainLibrary); @@ -1537,8 +1536,8 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap { @override Spannable getSpannable(MemberEntity member, ir.Node node) => node is ir.TreeNode - ? computeSourceSpanFromTreeNode(node) - : getSourceSpan(member, null); + ? computeSourceSpanFromTreeNode(node) + : getSourceSpan(member, null); Iterable get libraryListInternal { return libraryMap.values; @@ -1565,8 +1564,9 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap { int index = declaration.typeParameters.indexOf(node); if (declaration.kind == ir.ProcedureKind.Factory) { ir.Class cls = declaration.enclosingClass!; - typeVariableMap[node] = - typeVariable = getTypeVariableInternal(cls.typeParameters[index]); + typeVariableMap[node] = typeVariable = getTypeVariableInternal( + cls.typeParameters[index], + ); } } } @@ -1754,10 +1754,9 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap { ); classes.register(container, containerData, ContextEnv(memberMap)); - InterfaceType? memberThisType = - member.enclosingClass != null - ? elementEnvironment.getThisType(member.enclosingClass!) - : null; + InterfaceType? memberThisType = member.enclosingClass != null + ? elementEnvironment.getThisType(member.enclosingClass!) + : null; for (ir.VariableDeclaration variable in info.boxedVariables) { boxedFields[variable] = _constructContextFieldEntry( memberThisType, @@ -1804,12 +1803,12 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap { InterfaceType supertype, { required bool createSignatureMethod, }) { - InterfaceType? memberThisType = - member.enclosingClass != null - ? elementEnvironment.getThisType(member.enclosingClass!) - : null; - ClassTypeVariableAccess typeVariableAccess = - members.getData(member as JMember).classTypeVariableAccess; + InterfaceType? memberThisType = member.enclosingClass != null + ? elementEnvironment.getThisType(member.enclosingClass!) + : null; + ClassTypeVariableAccess typeVariableAccess = members + .getData(member as JMember) + .classTypeVariableAccess; if (typeVariableAccess == ClassTypeVariableAccess.instanceField) { // A closure in a field initializer will only be executed in the // constructor and type variables are therefore accessed through @@ -2090,8 +2089,8 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap { typeVariableAccess, ), ); - memberMap[signatureMethod.memberName] = - closureClassInfo.signatureMethod = signatureMethod; + memberMap[signatureMethod.memberName] = closureClassInfo.signatureMethod = + signatureMethod; } JField _constructClosureField( diff --git a/pkg/compiler/lib/src/js_model/env.dart b/pkg/compiler/lib/src/js_model/env.dart index b40e6ad1e63..5ddd67b211b 100644 --- a/pkg/compiler/lib/src/js_model/env.dart +++ b/pkg/compiler/lib/src/js_model/env.dart @@ -714,20 +714,19 @@ mixin FunctionDataTypeVariablesMixin implements FunctionData { parent.kind == ir.ProcedureKind.Factory)) { _typeVariables = const []; } else { - _typeVariables = - functionNode.typeParameters.map(( - ir.TypeParameter typeParameter, - ) { - return elementMap - .getDartType( - ir.TypeParameterType( - typeParameter, - ir.Nullability.nonNullable, - ), - ) - .withoutNullability - as TypeVariableType; - }).toList(); + _typeVariables = functionNode.typeParameters.map(( + ir.TypeParameter typeParameter, + ) { + return elementMap + .getDartType( + ir.TypeParameterType( + typeParameter, + ir.Nullability.nonNullable, + ), + ) + .withoutNullability + as TypeVariableType; + }).toList(); } } } diff --git a/pkg/compiler/lib/src/js_model/js_strategy.dart b/pkg/compiler/lib/src/js_model/js_strategy.dart index dbb31167cdd..b09b7bed07b 100644 --- a/pkg/compiler/lib/src/js_model/js_strategy.dart +++ b/pkg/compiler/lib/src/js_model/js_strategy.dart @@ -226,10 +226,9 @@ class JsBackendStrategy { GlobalTypeInferenceResults globalTypeInferenceResults, ) { JClosedWorld closedWorld = globalTypeInferenceResults.closedWorld; - FixedNames fixedNames = - _compiler.options.enableMinification - ? const MinifiedFixedNames() - : const FixedNames(); + FixedNames fixedNames = _compiler.options.enableMinification + ? const MinifiedFixedNames() + : const FixedNames(); Tracer tracer = Tracer( closedWorld, @@ -239,8 +238,9 @@ class JsBackendStrategy { RuntimeTypesSubstitutions rtiSubstitutions; if (_compiler.options.disableRtiOptimization) { - final trivialSubs = - rtiSubstitutions = TrivialRuntimeTypesSubstitutions(closedWorld); + final trivialSubs = rtiSubstitutions = TrivialRuntimeTypesSubstitutions( + closedWorld, + ); _rtiChecksBuilder = TrivialRuntimeTypesChecksBuilder( closedWorld, trivialSubs, @@ -341,12 +341,11 @@ class JsBackendStrategy { closedWorld.nativeData, ); FixedNames fixedNames = codegen.fixedNames; - _namer = - _compiler.options.enableMinification - ? _compiler.options.useFrequencyNamer - ? FrequencyBasedNamer(closedWorld, fixedNames) - : MinifyNamer(closedWorld, fixedNames) - : Namer(closedWorld, fixedNames); + _namer = _compiler.options.enableMinification + ? _compiler.options.useFrequencyNamer + ? FrequencyBasedNamer(closedWorld, fixedNames) + : MinifyNamer(closedWorld, fixedNames) + : Namer(closedWorld, fixedNames); _nativeCodegenEnqueuer = NativeCodegenEnqueuer( _compiler.options, closedWorld.elementEnvironment, diff --git a/pkg/compiler/lib/src/js_model/js_to_frontend_map.dart b/pkg/compiler/lib/src/js_model/js_to_frontend_map.dart index c920a2afdd9..e47986c4b71 100644 --- a/pkg/compiler/lib/src/js_model/js_to_frontend_map.dart +++ b/pkg/compiler/lib/src/js_model/js_to_frontend_map.dart @@ -78,11 +78,11 @@ class JsToFrontendMap { DartType? toBackendType(DartType? type, {bool allowFreeVariables = false}) => type == null - ? null - : _TypeConverter( - _backend.types, - allowFreeVariables: allowFreeVariables, - ).visit(type, toBackendEntity); + ? null + : _TypeConverter( + _backend.types, + allowFreeVariables: allowFreeVariables, + ).visit(type, toBackendEntity); void registerClosureData(ClosureData closureData) { assert(_closureData == null, "Closure data has already been registered."); @@ -360,10 +360,9 @@ class _ConstantConverter implements ConstantValueVisitor { DartType type = typeConverter.visit(constant.type, toBackendEntity); List values = _handleValues(constant.values); final constantIndex = constant.indexObject; - final indexObject = - constantIndex == null - ? null - : visitJavaScriptObject(constantIndex, null); + final indexObject = constantIndex == null + ? null + : visitJavaScriptObject(constantIndex, null); if (identical(values, constant.values) && identical(indexObject, constant.indexObject) && type == constant.type) { @@ -385,10 +384,9 @@ class _ConstantConverter implements ConstantValueVisitor { final keyList = visitList(constant.keyList, null); final valueList = visitList(constant.valueList, null); final constantIndex = constant.indexObject; - final indexObject = - constantIndex == null - ? null - : visitJavaScriptObject(constantIndex, null); + final indexObject = constantIndex == null + ? null + : visitJavaScriptObject(constantIndex, null); if (identical(keyList, constant.keyList) && identical(valueList, constant.valueList) && identical(indexObject, constant.indexObject) && diff --git a/pkg/compiler/lib/src/js_model/js_world.dart b/pkg/compiler/lib/src/js_model/js_world.dart index 773602aa305..6dc5b0a638d 100644 --- a/pkg/compiler/lib/src/js_model/js_world.dart +++ b/pkg/compiler/lib/src/js_model/js_world.dart @@ -192,11 +192,13 @@ class JClosedWorld implements World { Set implementedClasses = source.readClasses().toSet(); Set liveNativeClasses = source.readClasses().toSet(); - Set extractTypeArgumentsInterfaces = - source.readClasses().toSet(); + Set extractTypeArgumentsInterfaces = source + .readClasses() + .toSet(); Set liveInstanceMembers = source.readMembers().toSet(); - Set liveAbstractInstanceMembers = - source.readMembers().toSet(); + Set liveAbstractInstanceMembers = source + .readMembers() + .toSet(); Set assignedInstanceMembers = source.readMembers().toSet(); Set processedMembers = source.readMembers().toSet(); Map> mixinUses = source.readClassMap( @@ -540,8 +542,9 @@ class JClosedWorld implements World { return false; } - late final ClassEntity _functionLub = - getLubOfInstantiatedSubtypes(commonElements.functionClass)!; + late final ClassEntity _functionLub = getLubOfInstantiatedSubtypes( + commonElements.functionClass, + )!; /// Returns `true` if [selector] on [receiver] can hit a `call` method on a /// subclass of `Closure` using the [abstractValueDomain]. diff --git a/pkg/compiler/lib/src/js_model/js_world_builder.dart b/pkg/compiler/lib/src/js_model/js_world_builder.dart index f0cc48c8526..e2df21345a2 100644 --- a/pkg/compiler/lib/src/js_model/js_world_builder.dart +++ b/pkg/compiler/lib/src/js_model/js_world_builder.dart @@ -314,14 +314,15 @@ class JClosedWorldBuilder { Set helperClassesUsed = map.toBackendClassSet( backendUsage.helperClassesUsed, ); - Set runtimeTypeUses = - backendUsage.runtimeTypeUses.map((RuntimeTypeUse runtimeTypeUse) { - return RuntimeTypeUse( - runtimeTypeUse.kind, - map.toBackendType(runtimeTypeUse.receiverType)!, - map.toBackendType(runtimeTypeUse.argumentType), - ); - }).toSet(); + Set runtimeTypeUses = backendUsage.runtimeTypeUses.map(( + RuntimeTypeUse runtimeTypeUse, + ) { + return RuntimeTypeUse( + runtimeTypeUse.kind, + map.toBackendType(runtimeTypeUse.receiverType)!, + map.toBackendType(runtimeTypeUse.argumentType), + ); + }).toSet(); return BackendUsageImpl( globalFunctionDependencies: globalFunctionDependencies, diff --git a/pkg/compiler/lib/src/js_model/records.dart b/pkg/compiler/lib/src/js_model/records.dart index 72a725e50c3..4a3220d8d6b 100644 --- a/pkg/compiler/lib/src/js_model/records.dart +++ b/pkg/compiler/lib/src/js_model/records.dart @@ -287,18 +287,16 @@ class RecordDataBuilder { ) { // Sorted shapes lead to a more consistent class ordering in the generated // code. - final shapes = - recordTypes.map((type) => type.shape).toSet().toList() - ..sort(RecordShape.compare); + final shapes = recordTypes.map((type) => type.shape).toSet().toList() + ..sort(RecordShape.compare); List representations = []; for (int i = 0; i < shapes.length; i++) { final shape = shapes[i]; final getters = []; - final cls = - shape.fieldCount == 0 - ? _elementMap.commonElements.emptyRecordClass - : closedWorldBuilder.buildRecordShapeClass(shape, getters); + final cls = shape.fieldCount == 0 + ? _elementMap.commonElements.emptyRecordClass + : closedWorldBuilder.buildRecordShapeClass(shape, getters); _gettersByShape[shape] = getters; int shapeTag = i; bool usesList = _computeUsesGeneralClass(cls); diff --git a/pkg/compiler/lib/src/js_model/type_recipe.dart b/pkg/compiler/lib/src/js_model/type_recipe.dart index 371e3ec327d..cea03e8b401 100644 --- a/pkg/compiler/lib/src/js_model/type_recipe.dart +++ b/pkg/compiler/lib/src/js_model/type_recipe.dart @@ -639,8 +639,9 @@ class _Substitution extends DartTypeSubstitutionVisitor { Null argument, bool freshReference, ) { - DartType? replacement = - _lookupCache[variable] ??= _lookupTypeVariableType(variable); + DartType? replacement = _lookupCache[variable] ??= _lookupTypeVariableType( + variable, + ); if (replacement == null) return variable; // not substituted. if (!freshReference) return replacement; int count = _counts[variable] = (_counts[variable] ?? 0) + 1; diff --git a/pkg/compiler/lib/src/kernel/element_map_impl.dart b/pkg/compiler/lib/src/kernel/element_map_impl.dart index 273864ac281..282b3cb3965 100644 --- a/pkg/compiler/lib/src/kernel/element_map_impl.dart +++ b/pkg/compiler/lib/src/kernel/element_map_impl.dart @@ -292,8 +292,10 @@ class KernelToElementMap implements IrToElementMap { if (data.thisType == null) { ir.Class node = data.node; if (node.typeParameters.isEmpty) { - data.thisType = - data.rawType = types.interfaceType(cls, const []); + data.thisType = data.rawType = types.interfaceType( + cls, + const [], + ); } else { data.thisType = types.interfaceType( cls, @@ -370,11 +372,10 @@ class KernelToElementMap implements IrToElementMap { Set canonicalSupertypes = {}; InterfaceType processSupertype(ir.Supertype supertypeNode) { - supertypeNode = - classHierarchy.getClassAsInstanceOf( - node, - supertypeNode.classNode, - )!; + supertypeNode = classHierarchy.getClassAsInstanceOf( + node, + supertypeNode.classNode, + )!; InterfaceType supertype = _typeConverter.visitSupertype( supertypeNode, ); @@ -1001,8 +1002,8 @@ class KernelToElementMap implements IrToElementMap { // library. // TODO(johnniwinther): Cache more results to avoid redundant lookups? cachedMayLookupInMain ??= - // Tests permit lookup outside of dart: libraries. - allowedNativeTest(elementEnvironment.mainLibrary!.canonicalUri); + // Tests permit lookup outside of dart: libraries. + allowedNativeTest(elementEnvironment.mainLibrary!.canonicalUri); DartType? type; if (cachedMayLookupInMain!) { type ??= findInLibrary(elementEnvironment.mainLibrary); @@ -1527,8 +1528,9 @@ class KernelToElementMap implements IrToElementMap { NativeBasicData get nativeBasicData { var data = _nativeBasicData; if (data == null) { - data = - _nativeBasicData = nativeBasicDataBuilder.close(elementEnvironment); + data = _nativeBasicData = nativeBasicDataBuilder.close( + elementEnvironment, + ); assert( _nativeBasicData != null, failedAt( @@ -1631,13 +1633,12 @@ class KernelToElementMap implements IrToElementMap { } else if (node is ir.FunctionExpression) { function = node.function; } - localFunction = - localFunctionMap[node] = JLocalFunction( - name, - memberContext, - executableContext, - node, - ); + localFunction = localFunctionMap[node] = JLocalFunction( + name, + memberContext, + executableContext, + node, + ); int index = 0; List typeVariables = []; for (ir.TypeParameter typeParameter in function.typeParameters) { diff --git a/pkg/compiler/lib/src/kernel/env.dart b/pkg/compiler/lib/src/kernel/env.dart index 04f2372cee8..fdba21d13ea 100644 --- a/pkg/compiler/lib/src/kernel/env.dart +++ b/pkg/compiler/lib/src/kernel/env.dart @@ -557,20 +557,19 @@ class KFunctionData extends KMemberData { parent.kind == ir.ProcedureKind.Factory)) { _typeVariables = const []; } else { - _typeVariables = - functionNode.typeParameters.map(( - ir.TypeParameter typeParameter, - ) { - return elementMap - .getDartType( - ir.TypeParameterType( - typeParameter, - ir.Nullability.nonNullable, - ), - ) - .withoutNullability - as TypeVariableType; - }).toList(); + _typeVariables = functionNode.typeParameters.map(( + ir.TypeParameter typeParameter, + ) { + return elementMap + .getDartType( + ir.TypeParameterType( + typeParameter, + ir.Nullability.nonNullable, + ), + ) + .withoutNullability + as TypeVariableType; + }).toList(); } } } diff --git a/pkg/compiler/lib/src/kernel/front_end_adapter.dart b/pkg/compiler/lib/src/kernel/front_end_adapter.dart index 68a568d5546..6293ed39f54 100644 --- a/pkg/compiler/lib/src/kernel/front_end_adapter.dart +++ b/pkg/compiler/lib/src/kernel/front_end_adapter.dart @@ -117,10 +117,9 @@ void reportFrontEndMessage( Iterable? relatedInformation = fe .getMessageRelatedInformation(message); DiagnosticMessage mainMessage = convertMessage(message); - List infos = - relatedInformation != null - ? relatedInformation.map(convertMessage).toList() - : const []; + List infos = relatedInformation != null + ? relatedInformation.map(convertMessage).toList() + : const []; switch (message.severity) { case fe.Severity.internalProblem: throw mainMessage.message.message; diff --git a/pkg/compiler/lib/src/kernel/kernel_impact.dart b/pkg/compiler/lib/src/kernel/kernel_impact.dart index d0aa02a0246..6f1c9db54ad 100644 --- a/pkg/compiler/lib/src/kernel/kernel_impact.dart +++ b/pkg/compiler/lib/src/kernel/kernel_impact.dart @@ -400,17 +400,17 @@ class KernelImpactConverter implements ImpactRegistry { impactBuilder.registerStaticUse( isConst ? StaticUse.constConstructorInvoke( - constructor, - callStructure, - elementMap.getInterfaceType(type), - deferredImport, - ) + constructor, + callStructure, + elementMap.getInterfaceType(type), + deferredImport, + ) : StaticUse.typedConstructorInvoke( - constructor, - callStructure, - elementMap.getInterfaceType(type), - deferredImport, - ), + constructor, + callStructure, + elementMap.getInterfaceType(type), + deferredImport, + ), ); if (type.typeArguments.any((ir.DartType type) => type is! ir.DynamicType)) { registerBackendImpact(_impacts.typeVariableBoundCheck); @@ -808,8 +808,9 @@ class KernelImpactConverter implements ImpactRegistry { ir.DartType? argumentType, ) { DartType receiverDartType = elementMap.getDartType(receiverType); - DartType? argumentDartType = - argumentType == null ? null : elementMap.getDartType(argumentType); + DartType? argumentDartType = argumentType == null + ? null + : elementMap.getDartType(argumentType); // Enable runtime type support if we discover a getter called // runtimeType. We have to enable runtime type before hitting the @@ -1030,8 +1031,9 @@ class KernelImpactConverter implements ImpactRegistry { final conditionalUse = ConditionalUse.withReplacement( impact: convert(impact.impactData), replacementImpact: convert(impact.replacementImpactData), - originalConditions: - impact.originalConditions.map(elementMap.getMember).toList(), + originalConditions: impact.originalConditions + .map(elementMap.getMember) + .toList(), original: impact.original, replacement: impact.replacement, ); diff --git a/pkg/compiler/lib/src/kernel/kernel_strategy.dart b/pkg/compiler/lib/src/kernel/kernel_strategy.dart index eec27385080..9fde69be5d6 100644 --- a/pkg/compiler/lib/src/kernel/kernel_strategy.dart +++ b/pkg/compiler/lib/src/kernel/kernel_strategy.dart @@ -53,8 +53,8 @@ class KernelFrontendStrategy { late final KernelToElementMap _elementMap; late final RuntimeTypesNeedBuilder _runtimeTypesNeedBuilder = _options.disableRtiOptimization - ? const TrivialRuntimeTypesNeedBuilder() - : RuntimeTypesNeedBuilderImpl(elementEnvironment); + ? const TrivialRuntimeTypesNeedBuilder() + : RuntimeTypesNeedBuilderImpl(elementEnvironment); RuntimeTypesNeedBuilder get runtimeTypesNeedBuilderForTesting => _runtimeTypesNeedBuilder; @@ -125,11 +125,8 @@ class KernelFrontendStrategy { MemberEntity member, ) { if (!member.isInstanceMember) return; - MemberEntity interceptorMember = - elementEnvironment.lookupLocalClassMember( - interceptorClass, - member.memberName, - )!; + MemberEntity interceptorMember = elementEnvironment + .lookupLocalClassMember(interceptorClass, member.memberName)!; // Interceptors must override all Object methods due to calling convention // differences. assert( diff --git a/pkg/compiler/lib/src/kernel/kernel_world.dart b/pkg/compiler/lib/src/kernel/kernel_world.dart index 03a3199fb8f..0f7f7b9f417 100644 --- a/pkg/compiler/lib/src/kernel/kernel_world.dart +++ b/pkg/compiler/lib/src/kernel/kernel_world.dart @@ -193,20 +193,19 @@ class KClosedWorld implements BuiltWorld { } @override - late final Iterable userNoSuchMethods = - (() { - final result = []; - liveMemberUsage.forEach((MemberEntity member, MemberUsage memberUsage) { - if (member is FunctionEntity && memberUsage.hasUse) { - if (member.isInstanceMember && - member.name == Identifiers.noSuchMethod_ && - !commonElements.isDefaultNoSuchMethodImplementation(member)) { - result.add(member); - } - } - }); - return result; - })(); + late final Iterable userNoSuchMethods = (() { + final result = []; + liveMemberUsage.forEach((MemberEntity member, MemberUsage memberUsage) { + if (member is FunctionEntity && memberUsage.hasUse) { + if (member.isInstanceMember && + member.name == Identifiers.noSuchMethod_ && + !commonElements.isDefaultNoSuchMethodImplementation(member)) { + result.add(member); + } + } + }); + return result; + })(); @override late final Iterable closurizedMembers = (() { @@ -220,49 +219,46 @@ class KClosedWorld implements BuiltWorld { }()); @override - late final Iterable closurizedStatics = - (() { - final result = {}; - liveMemberUsage.forEach((MemberEntity member, MemberUsage usage) { - if (member.isFunction && - (member.isStatic || member.isTopLevel) && - usage.hasRead) { - result.add(member as FunctionEntity); - } - }); - return result; - })(); + late final Iterable closurizedStatics = (() { + final result = {}; + liveMemberUsage.forEach((MemberEntity member, MemberUsage usage) { + if (member.isFunction && + (member.isStatic || member.isTopLevel) && + usage.hasRead) { + result.add(member as FunctionEntity); + } + }); + return result; + })(); @override - late final Map genericCallableProperties = - (() { - final result = {}; - liveMemberUsage.forEach((MemberEntity member, MemberUsage usage) { - if (usage.hasRead) { - DartType? type; - if (member is FieldEntity) { - type = elementEnvironment.getFieldType(member); - } else if (member.isGetter) { - type = - elementEnvironment - .getFunctionType(member as FunctionEntity) - .returnType; - } - if (type == null) return; - if (dartTypes.canAssignGenericFunctionTo(type)) { - result[member] = type; - } else { - type = type.withoutNullability; - if (type is InterfaceType) { - FunctionType? callType = dartTypes.getCallType(type); - if (callType != null && - dartTypes.canAssignGenericFunctionTo(callType)) { - result[member] = callType; - } - } + late final Map genericCallableProperties = (() { + final result = {}; + liveMemberUsage.forEach((MemberEntity member, MemberUsage usage) { + if (usage.hasRead) { + DartType? type; + if (member is FieldEntity) { + type = elementEnvironment.getFieldType(member); + } else if (member.isGetter) { + type = elementEnvironment + .getFunctionType(member as FunctionEntity) + .returnType; + } + if (type == null) return; + if (dartTypes.canAssignGenericFunctionTo(type)) { + result[member] = type; + } else { + type = type.withoutNullability; + if (type is InterfaceType) { + FunctionType? callType = dartTypes.getCallType(type); + if (callType != null && + dartTypes.canAssignGenericFunctionTo(callType)) { + result[member] = callType; } } - }); - return result; - })(); + } + } + }); + return result; + })(); } diff --git a/pkg/compiler/lib/src/kernel/native_basic_data.dart b/pkg/compiler/lib/src/kernel/native_basic_data.dart index 2cd6185a1f6..d7b0a2d2e44 100644 --- a/pkg/compiler/lib/src/kernel/native_basic_data.dart +++ b/pkg/compiler/lib/src/kernel/native_basic_data.dart @@ -104,7 +104,7 @@ class KernelAnnotationProcessor { // otherwise paying the cost to verify by indexing extension types. bool isObjectLiteralConstructor = (memberNode.isExtensionTypeMember && - memberNode.function?.namedParameters.isNotEmpty == true); + memberNode.function?.namedParameters.isNotEmpty == true); if (function.isExternal && (isExplicitlyJsLibrary || isObjectLiteralConstructor)) { // External members of explicit js-interop library are implicitly diff --git a/pkg/compiler/lib/src/kernel/transformations/global/clone_mixin_methods_with_super.dart b/pkg/compiler/lib/src/kernel/transformations/global/clone_mixin_methods_with_super.dart index 8dfa34e3974..5344b297f50 100644 --- a/pkg/compiler/lib/src/kernel/transformations/global/clone_mixin_methods_with_super.dart +++ b/pkg/compiler/lib/src/kernel/transformations/global/clone_mixin_methods_with_super.dart @@ -65,10 +65,9 @@ void transformClass(Class cls) { // TODO(jensj): Provide a "referenceFrom" if we need to support // the incremental compiler. ensureExistingProcedureMaps(); - Procedure? existingProcedure = - procedure.kind == ProcedureKind.Setter - ? existingSetters[procedure.name] - : existingNonSetters[procedure.name]; + Procedure? existingProcedure = procedure.kind == ProcedureKind.Setter + ? existingSetters[procedure.name] + : existingNonSetters[procedure.name]; if (existingProcedure != null) { cls.procedures.remove(existingProcedure); } diff --git a/pkg/compiler/lib/src/kernel/transformations/modular/late_lowering.dart b/pkg/compiler/lib/src/kernel/transformations/modular/late_lowering.dart index 36ac1a46657..16c487e3d00 100644 --- a/pkg/compiler/lib/src/kernel/transformations/modular/late_lowering.dart +++ b/pkg/compiler/lib/src/kernel/transformations/modular/late_lowering.dart @@ -104,14 +104,13 @@ class LateLowering { Name _mangleFieldName(Field field) { assert(_shouldLowerInstanceField(field)); final prefix = _lateInstanceFieldPrefix; - final suffix = - field.initializer == null - ? field.isFinal - ? _lateFinalUninitializedSuffix - : _lateAssignableUninitializedSuffix - : field.isFinal - ? _lateFinalInitializedSuffix - : _lateAssignableInitializedSuffix; + final suffix = field.initializer == null + ? field.isFinal + ? _lateFinalUninitializedSuffix + : _lateAssignableUninitializedSuffix + : field.isFinal + ? _lateFinalInitializedSuffix + : _lateAssignableInitializedSuffix; Class cls = field.enclosingClass!; return Name( @@ -122,8 +121,8 @@ class LateLowering { ConstructorInvocation _callCellConstructor(Expression name, int fileOffset) => _omitLateNames - ? _callCellUnnamedConstructor(fileOffset) - : _callCellNamedConstructor(name, fileOffset); + ? _callCellUnnamedConstructor(fileOffset) + : _callCellNamedConstructor(name, fileOffset); ConstructorInvocation _callCellUnnamedConstructor(int fileOffset) => ConstructorInvocation( @@ -143,10 +142,9 @@ class LateLowering { Expression name, Expression initializer, int fileOffset, - ) => - _omitLateNames - ? _callInitializedCellUnnamedConstructor(initializer, fileOffset) - : _callInitializedCellNamedConstructor(name, initializer, fileOffset); + ) => _omitLateNames + ? _callInitializedCellUnnamedConstructor(initializer, fileOffset) + : _callInitializedCellNamedConstructor(name, initializer, fileOffset); ConstructorInvocation _callInitializedCellUnnamedConstructor( Expression initializer, @@ -326,10 +324,9 @@ class LateLowering { int fileOffset = node.fileOffset; VariableGet cell = _variableCellRead(variable, fileOffset); - _Reader reader = - variable.initializer == null - ? _readLocal - : (variable.isFinal ? _readInitializedFinal : _readInitialized); + _Reader reader = variable.initializer == null + ? _readLocal + : (variable.isFinal ? _readInitializedFinal : _readInitialized); return _callReader( reader, cell, @@ -346,14 +343,13 @@ class LateLowering { int fileOffset = node.fileOffset; VariableGet cell = _variableCellRead(variable, fileOffset); - Procedure setter = - variable.initializer == null - ? (variable.isFinal - ? _coreTypes.cellFinalLocalValueSetter - : _coreTypes.cellValueSetter) - : (variable.isFinal - ? _coreTypes.initializedCellFinalValueSetter - : _coreTypes.initializedCellValueSetter); + Procedure setter = variable.initializer == null + ? (variable.isFinal + ? _coreTypes.cellFinalLocalValueSetter + : _coreTypes.cellValueSetter) + : (variable.isFinal + ? _coreTypes.initializedCellFinalValueSetter + : _coreTypes.initializedCellValueSetter); return _callSetter(setter, cell, node.value, fileOffset); } diff --git a/pkg/compiler/lib/src/kernel/transformations/modular/transform.dart b/pkg/compiler/lib/src/kernel/transformations/modular/transform.dart index 310b48cd8ab..117a9c1dd7e 100644 --- a/pkg/compiler/lib/src/kernel/transformations/modular/transform.dart +++ b/pkg/compiler/lib/src/kernel/transformations/modular/transform.dart @@ -44,8 +44,8 @@ class _ModularTransformer extends Transformer { _awaitLowering = AwaitLowering(coreTypes), _asyncLowering = (options?.features.simpleAsyncToFuture.isEnabled ?? false) - ? AsyncLowering(coreTypes) - : null; + ? AsyncLowering(coreTypes) + : null; @override TreeNode defaultMember(Member node) { diff --git a/pkg/compiler/lib/src/native/enqueue.dart b/pkg/compiler/lib/src/native/enqueue.dart index 3b5b320663d..ddedf33cd47 100644 --- a/pkg/compiler/lib/src/native/enqueue.dart +++ b/pkg/compiler/lib/src/native/enqueue.dart @@ -298,8 +298,8 @@ class NativeCodegenEnqueuer extends NativeEnqueuer { _addSubtypes(superclass, emitter); _elementEnvironment.forEachSupertype(cls, (InterfaceType type) { - List subtypes = - emitter.subtypes[type.element] ??= []; + List subtypes = emitter.subtypes[type.element] ??= + []; subtypes.add(cls); }); @@ -311,8 +311,8 @@ class NativeCodegenEnqueuer extends NativeEnqueuer { superclass = _elementEnvironment.getSuperClass(superclass)!; } - List directSubtypes = - emitter.directSubtypes[superclass] ??= []; + List directSubtypes = emitter.directSubtypes[superclass] ??= + []; directSubtypes.add(cls); } diff --git a/pkg/compiler/lib/src/options.dart b/pkg/compiler/lib/src/options.dart index 1c979f07db7..6dda72aa8ca 100644 --- a/pkg/compiler/lib/src/options.dart +++ b/pkg/compiler/lib/src/options.dart @@ -722,25 +722,22 @@ class CompilerOptions implements DiagnosticOptions { /// extension does not match the expected extension for the current [stage] /// then the last segment is treated as a prefix. Only set when `--stage` is /// specified. - late final String _outputPrefix = - (() { - if (_stageFlag == null) return ''; - final extension = _outputExtension; + late final String _outputPrefix = (() { + if (_stageFlag == null) return ''; + final extension = _outputExtension; - return (extension != null && _outputFilename.endsWith(extension)) - ? '' - : _outputFilename; - })(); + return (extension != null && _outputFilename.endsWith(extension)) + ? '' + : _outputFilename; + })(); /// Output directory specified by the user via the `--out` flag. The directory /// is calculated by resolving the substring prior to the final URI segment /// (i.e. before the final slash) relative to [Uri.base]. Defaults to /// [Uri.base] if `--out` is not provided or does not include a directory. - late final Uri _outputDir = - (() => - (_outputUri != null) - ? Uri.base.resolveUri(_outputUri!).resolve('.') - : Uri.base)(); + late final Uri _outputDir = (() => (_outputUri != null) + ? Uri.base.resolveUri(_outputUri!).resolve('.') + : Uri.base)(); /// Computes a resolved output URI based on value provided via the `--out` /// flag. Updates [outputUri] based on the result and returns the value. @@ -835,8 +832,11 @@ class CompilerOptions implements DiagnosticOptions { options, Flags.benchmarkingExperiment, ) - ..buildId = - _extractStringOption(options, '--build-id=', _undeterminedBuildID)! + ..buildId = _extractStringOption( + options, + '--build-id=', + _undeterminedBuildID, + )! ..compileForServer = _hasOption(options, Flags.serverMode) ..deferredMapUri = _extractUriOption(options, '--deferred-map=') .._deferredLoadIdMapUri = _extractUriOption( @@ -887,8 +887,10 @@ class CompilerOptions implements DiagnosticOptions { .._disableMinification = _hasOption(options, Flags.noMinify) ..omitLateNames = _hasOption(options, Flags.omitLateNames) .._noOmitLateNames = _hasOption(options, Flags.noOmitLateNames) - ..enableNativeLiveTypeAnalysis = - !_hasOption(options, Flags.disableNativeLiveTypeAnalysis) + ..enableNativeLiveTypeAnalysis = !_hasOption( + options, + Flags.disableNativeLiveTypeAnalysis, + ) ..enableUserAssertions = _hasOption(options, Flags.enableCheckedMode) || _hasOption(options, Flags.enableAsserts) @@ -938,8 +940,10 @@ class CompilerOptions implements DiagnosticOptions { ) ..testMode = _hasOption(options, Flags.testMode) ..trustPrimitives = _hasOption(options, Flags.trustPrimitives) - ..useFrequencyNamer = - !_hasOption(options, Flags.noFrequencyBasedMinification) + ..useFrequencyNamer = !_hasOption( + options, + Flags.noFrequencyBasedMinification, + ) ..useMultiSourceInfo = _hasOption(options, Flags.useMultiSourceInfo) ..useNewSourceInfo = _hasOption(options, Flags.useNewSourceInfo) ..useSimpleLoadIds = _hasOption(options, Flags.useSimpleLoadIds) diff --git a/pkg/compiler/lib/src/ordered_typeset.dart b/pkg/compiler/lib/src/ordered_typeset.dart index 078084f8cee..b23ea1df976 100644 --- a/pkg/compiler/lib/src/ordered_typeset.dart +++ b/pkg/compiler/lib/src/ordered_typeset.dart @@ -146,8 +146,9 @@ class OrderedTypeSet { void forEach(int level, void Function(InterfaceType type) f) { if (level < levels) { Link pointer = _levels[level]; - Link end = - level > 0 ? _levels[level - 1] : const Link(); + Link end = level > 0 + ? _levels[level - 1] + : const Link(); // TODO(het): checking `isNotEmpty` should be unnecessary, remove when // constants are properly canonicalized while (pointer.isNotEmpty && !identical(pointer, end)) { @@ -161,8 +162,9 @@ class OrderedTypeSet { int level = hierarchyDepth; if (level < levels) { Link pointer = _levels[level]; - Link end = - level > 0 ? _levels[level - 1] : const Link(); + Link end = level > 0 + ? _levels[level - 1] + : const Link(); // TODO(het): checking `isNotEmpty` should be unnecessary, remove when // constants are properly canonicalized while (pointer.isNotEmpty && !identical(pointer, end)) { diff --git a/pkg/compiler/lib/src/serialization/deferrable.dart b/pkg/compiler/lib/src/serialization/deferrable.dart index 38fc00a493f..fb41b83dc9d 100644 --- a/pkg/compiler/lib/src/serialization/deferrable.dart +++ b/pkg/compiler/lib/src/serialization/deferrable.dart @@ -79,20 +79,18 @@ abstract class Deferrable { E Function(DataSourceReader source) f, int offset, { bool cacheData = true, - }) => - cacheData - ? _DeferredCache(reader, f, offset) - : _Deferred(reader, f, offset); + }) => cacheData + ? _DeferredCache(reader, f, offset) + : _Deferred(reader, f, offset); static Deferrable deferredWithArg( DataSourceReader reader, E Function(DataSourceReader source, A arg) f, A arg, int offset, { bool cacheData = true, - }) => - cacheData - ? _DeferredCacheWithArg(reader, f, arg, offset) - : _DeferredWithArg(reader, f, arg, offset); + }) => cacheData + ? _DeferredCacheWithArg(reader, f, arg, offset) + : _DeferredWithArg(reader, f, arg, offset); const factory Deferrable.eager(E data) = _Eager; const Deferrable(); diff --git a/pkg/compiler/lib/src/serialization/indexed_sink_source.dart b/pkg/compiler/lib/src/serialization/indexed_sink_source.dart index 8d0475e25d6..4d9a42bd1e0 100644 --- a/pkg/compiler/lib/src/serialization/indexed_sink_source.dart +++ b/pkg/compiler/lib/src/serialization/indexed_sink_source.dart @@ -234,8 +234,9 @@ class UnorderedIndexedSource implements IndexedSource { offset = markerOrOffset - _indicatorOffset; } bool isLocal = _isLocalOffset(offset); - final globalOffset = - isLocal ? _localToGlobalOffset(offset, source) : offset; + final globalOffset = isLocal + ? _localToGlobalOffset(offset, source) + : offset; final cachedValue = _cache[globalOffset]; if (cachedValue != null) return cachedValue; return _readAtOffset( @@ -268,8 +269,9 @@ class UnorderedIndexedSource implements IndexedSource { offset = markerOrOffset - _indicatorOffset; } bool isLocal = _isLocalOffset(offset); - final globalOffset = - isLocal ? _localToGlobalOffset(offset, source) : offset; + final globalOffset = isLocal + ? _localToGlobalOffset(offset, source) + : offset; return _readAtOffset( source, readValue, @@ -299,13 +301,12 @@ class UnorderedIndexedSource implements IndexedSource { }) { final realSource = isLocal ? source : findSource(globalOffset); final realOffset = _globalToRealOffset(globalOffset, realSource); - final value = - isLocal - ? source.readWithOffset(realOffset, readValue) - : source.readWithSource( - realSource, - () => source.readWithOffset(realOffset, readValue), - ); + final value = isLocal + ? source.readWithOffset(realOffset, readValue) + : source.readWithSource( + realSource, + () => source.readWithOffset(realOffset, readValue), + ); if (isCached) _cache[globalOffset] = value; return value; } diff --git a/pkg/compiler/lib/src/serialization/member_data.dart b/pkg/compiler/lib/src/serialization/member_data.dart index 92c49f0a7be..651ebe393c7 100644 --- a/pkg/compiler/lib/src/serialization/member_data.dart +++ b/pkg/compiler/lib/src/serialization/member_data.dart @@ -36,9 +36,9 @@ String computeMemberName(ir.Member member) { // forwarders (see dartbug.com/33732). String libraryPrefix = member.name.isPrivate && - member.name.libraryReference != member.enclosingLibrary.reference - ? '${member.name.libraryReference?.canonicalName?.name}:' - : ''; + member.name.libraryReference != member.enclosingLibrary.reference + ? '${member.name.libraryReference?.canonicalName?.name}:' + : ''; String name = member.name.text; if (member is ir.Constructor) { name = '.$name'; @@ -271,14 +271,14 @@ class MemberData { } ir.Constant getConstantByIndex(ir.ConstantExpression node, int index) { - ConstantNodeIndexerVisitor indexer = - _constantIndexMap[node] ??= _createConstantIndexer(node); + ConstantNodeIndexerVisitor indexer = _constantIndexMap[node] ??= + _createConstantIndexer(node); return indexer.getConstant(index); } int getIndexByConstant(ir.ConstantExpression node, ir.Constant constant) { - ConstantNodeIndexerVisitor indexer = - _constantIndexMap[node] ??= _createConstantIndexer(node); + ConstantNodeIndexerVisitor indexer = _constantIndexMap[node] ??= + _createConstantIndexer(node); return indexer.getIndex(constant); } diff --git a/pkg/compiler/lib/src/serialization/sink.dart b/pkg/compiler/lib/src/serialization/sink.dart index b9f01b4f494..f3792ea9b8c 100644 --- a/pkg/compiler/lib/src/serialization/sink.dart +++ b/pkg/compiler/lib/src/serialization/sink.dart @@ -1194,8 +1194,8 @@ class DataSinkWriter { MemberData get currentMemberData { final currentMemberContext = _currentMemberContext!; - return _currentMemberData ??= - _memberData[currentMemberContext] ??= MemberData(currentMemberContext); + return _currentMemberData ??= _memberData[currentMemberContext] ??= + MemberData(currentMemberContext); } MemberData _getMemberData(ir.TreeNode node) { diff --git a/pkg/compiler/lib/src/serialization/source.dart b/pkg/compiler/lib/src/serialization/source.dart index be445e39daa..23115008096 100644 --- a/pkg/compiler/lib/src/serialization/source.dart +++ b/pkg/compiler/lib/src/serialization/source.dart @@ -183,11 +183,11 @@ class DataSourceReader { }) { return useDeferredStrategy ? Deferrable.deferred( - this, - f, - _sourceReader.readDeferred(), - cacheData: cacheData, - ) + this, + f, + _sourceReader.readDeferred(), + cacheData: cacheData, + ) : Deferrable.eager(_sourceReader.readDeferredAsEager(() => f(this))); } @@ -198,15 +198,15 @@ class DataSourceReader { }) { return useDeferredStrategy ? Deferrable.deferredWithArg( - this, - f, - arg, - _sourceReader.readDeferred(), - cacheData: cacheData, - ) + this, + f, + arg, + _sourceReader.readDeferred(), + cacheData: cacheData, + ) : Deferrable.eager( - _sourceReader.readDeferredAsEager(() => f(this, arg)), - ); + _sourceReader.readDeferredAsEager(() => f(this, arg)), + ); } /// Invoke [f] in the context of [member]. This sets up support for @@ -852,10 +852,12 @@ class DataSourceReader { )..addAll(typeParameters); for (int index = 0; index < typeParameterCount; index++) { typeParameters[index].name = readString(); - typeParameters[index].bound = - _readDartTypeNode(functionTypeVariables)!; - typeParameters[index].defaultType = - _readDartTypeNode(functionTypeVariables)!; + typeParameters[index].bound = _readDartTypeNode( + functionTypeVariables, + )!; + typeParameters[index].defaultType = _readDartTypeNode( + functionTypeVariables, + )!; } ir.DartType returnType = _readDartTypeNode(functionTypeVariables)!; ir.Nullability nullability = readEnum(ir.Nullability.values); @@ -1293,10 +1295,9 @@ class DataSourceReader { final keyList = readConstant() as ListConstantValue; final valueList = readConstant() as ListConstantValue; bool onlyStringKeys = readBool(); - final indexObject = - onlyStringKeys - ? readConstant() as JavaScriptObjectConstantValue - : null; + final indexObject = onlyStringKeys + ? readConstant() as JavaScriptObjectConstantValue + : null; return constant_system.JavaScriptMapConstant( type, keyList, diff --git a/pkg/compiler/lib/src/serialization/task.dart b/pkg/compiler/lib/src/serialization/task.dart index 9f7da87bea4..ecd084ec80e 100644 --- a/pkg/compiler/lib/src/serialization/task.dart +++ b/pkg/compiler/lib/src/serialization/task.dart @@ -53,8 +53,9 @@ class SerializationTask extends CompilerTask { this._provider, this._outputProvider, Measurer measurer, - ) : _valueInterner = - _options.features.internValues.isEnabled ? ValueInterner() : null, + ) : _valueInterner = _options.features.internValues.isEnabled + ? ValueInterner() + : null, super(measurer); @override diff --git a/pkg/compiler/lib/src/source_file_provider.dart b/pkg/compiler/lib/src/source_file_provider.dart index ade8156c499..e368e616f4d 100644 --- a/pkg/compiler/lib/src/source_file_provider.dart +++ b/pkg/compiler/lib/src/source_file_provider.dart @@ -302,10 +302,9 @@ class FormattingDiagnosticHandler implements api.CompilerDiagnostics { file.getLocationMessage(color(message), begin, end, colorize: color), ); } else { - String position = - begin != null && end != null && end - begin > 0 - ? '@$begin+${end - begin}' - : ''; + String position = begin != null && end != null && end - begin > 0 + ? '@$begin+${end - begin}' + : ''; print( '${provider.relativizeUri(uri)}$position:\n' '${color(message)}', @@ -415,8 +414,9 @@ class RandomAccessFileOutputProvider implements api.CompilerOutput { RandomAccessFile output; try { - output = (File(uri.toFilePath()) - ..createSync(recursive: true)).openSync(mode: FileMode.write); + output = (File( + uri.toFilePath(), + )..createSync(recursive: true)).openSync(mode: FileMode.write); } on FileSystemException catch (e) { onFailure('$e'); } @@ -450,8 +450,9 @@ class RandomAccessFileOutputProvider implements api.CompilerOutput { RandomAccessFile output; try { - output = (File(uri.toFilePath()) - ..createSync(recursive: true)).openSync(mode: FileMode.write); + output = (File( + uri.toFilePath(), + )..createSync(recursive: true)).openSync(mode: FileMode.write); } on FileSystemException catch (e) { onFailure('$e'); } diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart index ed2fd943f9f..8b93d4ab955 100644 --- a/pkg/compiler/lib/src/ssa/builder.dart +++ b/pkg/compiler/lib/src/ssa/builder.dart @@ -190,8 +190,8 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault _loopHandler = KernelLoopHandler(this); _typeBuilder = KernelTypeBuilder(this, _elementMap); graph.element = targetElement; - graph.sourceInformation = - _sourceInformationBuilder.buildVariableDeclaration(); + graph.sourceInformation = _sourceInformationBuilder + .buildVariableDeclaration(); localsHandler = LocalsHandler( this, targetElement, @@ -352,10 +352,9 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault AbstractValue type, { bool isElided = false, }) { - HLocalValue result = - isElided - ? HLocalValue(parameter, type) - : HParameterValue(parameter, type); + HLocalValue result = isElided + ? HLocalValue(parameter, type) + : HParameterValue(parameter, type); if (lastAddedParameter == null) { graph.entry.addBefore(graph.entry.first, result); } else { @@ -435,16 +434,16 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault KernelToTypeInferenceMapImpl(member, globalInferenceResults), _currentFrame != null ? _currentFrame!.sourceInformationBuilder.forContext( - member, - callSourceInformation, - ) + member, + callSourceInformation, + ) : _sourceInformationStrategy.createBuilderForContext(member), memberNode != null ? ir.StaticTypeContext( - memberNode, - elementMap.typeEnvironment, - cache: ir.StaticTypeCacheImpl(), - ) + memberNode, + elementMap.typeEnvironment, + cache: ir.StaticTypeCacheImpl(), + ) : null, ); } @@ -1716,10 +1715,9 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault if (options.experimentUnreachableMethodsThrow) { var emptyParameters = parameters.values.where( - (parameter) => - _abstractValueDomain - .isEmpty(parameter.instructionType) - .isDefinitelyTrue, + (parameter) => _abstractValueDomain + .isEmpty(parameter.instructionType) + .isDefinitelyTrue, ); if (emptyParameters.isNotEmpty) { _addComment('$emptyParameters inferred as [empty]'); @@ -2199,15 +2197,13 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault handleParameter(functionNode.positionalParameters[position]); } if (functionNode.namedParameters.isNotEmpty) { - List namedParameters = - functionNode.namedParameters - // Filter elided parameters. - .where( - (p) => function.parameterStructure.namedParameters.contains( - p.name, - ), - ) - .toList(); + List namedParameters = functionNode + .namedParameters + // Filter elided parameters. + .where( + (p) => function.parameterStructure.namedParameters.contains(p.name), + ) + .toList(); // Sort by file offset to visit parameters in declaration order. namedParameters.sort(nativeOrdering); namedParameters.forEach(handleParameter); @@ -2724,10 +2720,9 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault node.iterable.accept(this); array = pop(); - isFixed = - _abstractValueDomain - .isFixedLengthJsIndexable(array.instructionType) - .isDefinitelyTrue; + isFixed = _abstractValueDomain + .isFixedLengthJsIndexable(array.instructionType) + .isDefinitelyTrue; localsHandler.updateLocal( indexVariable, graph.addConstantInt(0, closedWorld), @@ -2775,10 +2770,9 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault // the condition. HInstruction value = HIndex(array, index, type) ..sourceInformation = sourceInformation; - final staticType = - _abstractValueDomain - .createFromStaticType(_getStaticForInElementType(node)) - .abstractValue; + final staticType = _abstractValueDomain + .createFromStaticType(_getStaticForInElementType(node)) + .abstractValue; value.instructionType = _abstractValueDomain.intersection( value.instructionType, staticType, @@ -3730,8 +3724,9 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault // TODO(https://dartbug.com/51777): Consider alternative with single switch // statement. - JumpTarget switchTarget = - _localsMap.getJumpTargetForSwitch(switchStatement)!; + JumpTarget switchTarget = _localsMap.getJumpTargetForSwitch( + switchStatement, + )!; localsHandler.updateLocal(switchTarget, graph.addConstantNull(closedWorld)); var switchCases = List.from(switchStatement.cases); @@ -5497,10 +5492,9 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault final receiverStaticType = _getStaticType( invocation.arguments.positional[1], ); - AbstractValue receiverType = - _abstractValueDomain - .createFromStaticType(receiverStaticType) - .abstractValue; + AbstractValue receiverType = _abstractValueDomain + .createFromStaticType(receiverStaticType) + .abstractValue; push( HInvokeClosure( selector, @@ -5636,11 +5630,12 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault String name = _readStringLiteral(invocation.arguments.positional[0]); final typeArgumentsLiteral = invocation.arguments.positional[1] as ir.ListLiteral; - List typeArguments = - typeArgumentsLiteral.expressions.map((ir.Expression expression) { - final typeLiteral = expression as ir.TypeLiteral; - return _elementMap.getDartType(typeLiteral.type); - }).toList(); + List typeArguments = typeArgumentsLiteral.expressions.map(( + ir.Expression expression, + ) { + final typeLiteral = expression as ir.TypeLiteral; + return _elementMap.getDartType(typeLiteral.type); + }).toList(); final positionalArgumentsLiteral = invocation.arguments.positional[2] as ir.ListLiteral; @@ -6061,13 +6056,12 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault ); return; } - final globalName = - _foreignConstantStringArgument( - invocation, - 1, - 'JS_EMBEDDED_GLOBAL', - 'second ', - )!; + final globalName = _foreignConstantStringArgument( + invocation, + 1, + 'JS_EMBEDDED_GLOBAL', + 'second ', + )!; js.Template expr = js.js.expressionTemplateYielding( _emitter.generateEmbeddedGlobalAccess(globalName), ); @@ -6694,8 +6688,9 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault return; } - HInstruction checkedExpression = - _visitPositionalArguments(invocation.arguments).single; + HInstruction checkedExpression = _visitPositionalArguments( + invocation.arguments, + ).single; push( HIsLateSentinel(checkedExpression, _abstractValueDomain.boolType) ..sourceInformation = sourceInformation, @@ -6886,14 +6881,12 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault List typeArguments, SourceInformation? sourceInformation, ) { - AbstractValue typeBound = - _abstractValueDomain - .createFromStaticType(staticReceiverType) - .abstractValue; - receiverType = - receiverType == null - ? typeBound - : _abstractValueDomain.intersection(receiverType, typeBound); + AbstractValue typeBound = _abstractValueDomain + .createFromStaticType(staticReceiverType) + .abstractValue; + receiverType = receiverType == null + ? typeBound + : _abstractValueDomain.intersection(receiverType, typeBound); // We prefer to not inline certain operations on indexables, // because the constant folder will handle them better and turn @@ -7034,10 +7027,9 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault if (node is ir.InstanceInvocation || node is ir.FunctionInvocation || node is ir.InstanceGet) { - final staticType = - _abstractValueDomain - .createFromStaticType(_getStaticType(node as ir.Expression)) - .abstractValue; + final staticType = _abstractValueDomain + .createFromStaticType(_getStaticType(node as ir.Expression)) + .abstractValue; // Narrow to front-end inferred type, but only if `receiverType` is // disjoint with LegacyJavaScriptObject. Global type inference does not // trust the legacy js-interop methods, so we should not start doing so @@ -7106,8 +7098,10 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault // TODO(johnniwinther): can we elide those parameters? This should be // consistent with what we do with instance methods. final procedure = node as ir.Procedure; - List namedParameters = - procedure.function.namedParameters.toList(); + List namedParameters = procedure + .function + .namedParameters + .toList(); namedParameters.sort(nativeOrdering); for (ir.VariableDeclaration variable in namedParameters) { @@ -7146,10 +7140,9 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault var nativeBehavior = NativeBehavior()..sideEffects.setAllSideEffects(); - DartType type = - element is ConstructorEntity - ? _elementEnvironment.getThisType(element.enclosingClass) - : _elementEnvironment.getFunctionType(element).returnType; + DartType type = element is ConstructorEntity + ? _elementEnvironment.getThisType(element.enclosingClass) + : _elementEnvironment.getFunctionType(element).returnType; // Native behavior effects here are similar to native/behavior.dart. // The return type is dynamic because we don't trust js-interop type // declarations. @@ -7260,15 +7253,13 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault final functionType = expressionType.withoutNullability as FunctionType; bool typeArgumentsNeeded = _rtiNeed.methodNeedsTypeArguments(target); - List typeArguments = - node.typeArguments - .map( - (type) => - typeArgumentsNeeded - ? _elementMap.getDartType(type) - : _commonElements.dynamicType, - ) - .toList(); + List typeArguments = node.typeArguments + .map( + (type) => typeArgumentsNeeded + ? _elementMap.getDartType(type) + : _commonElements.dynamicType, + ) + .toList(); registry.registerGenericInstantiation( GenericInstantiation(functionType, typeArguments), ); @@ -8255,8 +8246,8 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault assert(selector.applies(function)); CallStructure callStructure = selector.callStructure; ParameterStructure parameterStructure = function.parameterStructure; - List selectorArgumentNames = - selector.callStructure.getOrderedNamedArguments(); + List selectorArgumentNames = selector.callStructure + .getOrderedNamedArguments(); bool methodNeedsTypeArguments = _rtiNeed.methodNeedsTypeArguments(function); List compiledArguments = []; @@ -8335,8 +8326,8 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault } else { assert(callStructure.typeArgumentCount == 0); // Pass type variable bounds as type arguments. - for (TypeVariableType typeVariable in _elementEnvironment - .getFunctionTypeVariables(function)) { + for (TypeVariableType typeVariable + in _elementEnvironment.getFunctionTypeVariables(function)) { compiledArguments.add( _computeTypeArgumentDefaultValue(function, typeVariable), ); @@ -8444,8 +8435,8 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault bool hasTypeParameters = function.parameterStructure.typeParameters > 0; bool needsTypeArguments = _rtiNeed.methodNeedsTypeArguments(function); - for (TypeVariableType typeVariable in _elementEnvironment - .getFunctionTypeVariables(function)) { + for (TypeVariableType typeVariable + in _elementEnvironment.getFunctionTypeVariables(function)) { HInstruction argument; if (hasTypeParameters && needsTypeArguments) { argument = compiledArguments[argumentIndex++]; diff --git a/pkg/compiler/lib/src/ssa/codegen.dart b/pkg/compiler/lib/src/ssa/codegen.dart index 28e2b9a086b..9be7a50407c 100644 --- a/pkg/compiler/lib/src/ssa/codegen.dart +++ b/pkg/compiler/lib/src/ssa/codegen.dart @@ -92,11 +92,11 @@ class SsaCodeGeneratorTask extends CompilerTask { return finish( element.asyncMarker.isAsync ? (element.asyncMarker.isYielding - ? js.AsyncModifier.asyncStar - : js.AsyncModifier.async) + ? js.AsyncModifier.asyncStar + : js.AsyncModifier.async) : (element.asyncMarker.isYielding - ? js.AsyncModifier.syncStar - : js.AsyncModifier.sync), + ? js.AsyncModifier.syncStar + : js.AsyncModifier.sync), ); } else { return finish(js.AsyncModifier.sync); @@ -2663,10 +2663,9 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { assert(_nativeData.isNativeMember(target), 'non-native target: $node'); - String? targetName = - _nativeData.hasFixedBackendName(target) - ? _nativeData.getFixedBackendName(target) - : target.name; + String? targetName = _nativeData.hasFixedBackendName(target) + ? _nativeData.getFixedBackendName(target) + : target.name; void invokeWithJavaScriptReceiver(js.Expression receiverExpression) { // JS-interop target names can be paths ("a.b"), so we parse them to @@ -2689,10 +2688,9 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { inputs, start: target.isInstanceMember ? 1 : 0, ); - template = - target is ConstructorEntity - ? 'new #.$targetName(#)' - : '#.$targetName(#)'; + template = target is ConstructorEntity + ? 'new #.$targetName(#)' + : '#.$targetName(#)'; templateInputs = [receiverExpression, arguments]; } js.Expression expression = js.js @@ -3313,11 +3311,10 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { } void generateArrayLiteral(HLiteralList node) { - List elements = - node.inputs.map((HInstruction input) { - use(input); - return pop(); - }).toList(); + List elements = node.inputs.map((HInstruction input) { + use(input); + return pop(); + }).toList(); push( js.ArrayInitializer( elements, diff --git a/pkg/compiler/lib/src/ssa/codegen_helpers.dart b/pkg/compiler/lib/src/ssa/codegen_helpers.dart index 01b0bf1aaa3..b0a2214484f 100644 --- a/pkg/compiler/lib/src/ssa/codegen_helpers.dart +++ b/pkg/compiler/lib/src/ssa/codegen_helpers.dart @@ -161,10 +161,9 @@ class SsaInstructionSelection extends HBaseVisitor // We also leave HIf nodes in place when one branch is dead. HInstruction condition = current.inputs.first; if (condition is HConstant) { - successor = - condition.constant is TrueConstantValue - ? current.thenBlock - : current.elseBlock; + successor = condition.constant is TrueConstantValue + ? current.thenBlock + : current.elseBlock; } } if (successor != null && successor.id > current.block!.id) { @@ -224,10 +223,9 @@ class SsaInstructionSelection extends HBaseVisitor // ToPrimitive conversions of an object occur when the other operand is a // primitive (Number, String, Symbol and, indirectly, Boolean). We use // 'intercepted' types as a proxy for all the primitive types. - bool _intercepted(AbstractValue type) => - _abstractValueDomain - .isInterceptor(_abstractValueDomain.excludeNull(type)) - .isPotentiallyTrue; + bool _intercepted(AbstractValue type) => _abstractValueDomain + .isInterceptor(_abstractValueDomain.excludeNull(type)) + .isPotentiallyTrue; @override HBinaryBitOp visitBinaryBitOp(HBinaryBitOp node) { diff --git a/pkg/compiler/lib/src/ssa/interceptor_simplifier.dart b/pkg/compiler/lib/src/ssa/interceptor_simplifier.dart index 3e31d8837b9..e3a6282ae30 100644 --- a/pkg/compiler/lib/src/ssa/interceptor_simplifier.dart +++ b/pkg/compiler/lib/src/ssa/interceptor_simplifier.dart @@ -216,10 +216,12 @@ class SsaSimplifyInterceptors extends HBaseVisitor // If multiple instructions are present in bestBlock, we scan bestBlock from // the start to find first instruction. If the [dominator] hint is in the // same block, can start from there instead. - Set set = - instructions.where((i) => i.block == bestBlock).toSet(); - HInstruction? current = - (dominator?.block == bestBlock) ? dominator : bestBlock.first; + Set set = instructions + .where((i) => i.block == bestBlock) + .toSet(); + HInstruction? current = (dominator?.block == bestBlock) + ? dominator + : bestBlock.first; while (current != null && !set.contains(current)) { current = current.next; } diff --git a/pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart b/pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart index 4cb3eb9bf8f..300749e3876 100644 --- a/pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart +++ b/pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart @@ -156,17 +156,16 @@ class InvokeDynamicSpecializer { HGetLength length = HGetLength( array, abstractValueDomain.positiveIntType, - isAssignable: - abstractValueDomain - .isFixedLengthJsIndexable(array.instructionType) - .isPotentiallyFalse, + isAssignable: abstractValueDomain + .isFixedLengthJsIndexable(array.instructionType) + .isPotentiallyFalse, ); block.addBefore(indexerNode, length); AbstractValue type = indexArgument.isPositiveInteger(abstractValueDomain).isDefinitelyTrue - ? indexArgument.instructionType - : abstractValueDomain.positiveIntType; + ? indexArgument.instructionType + : abstractValueDomain.positiveIntType; HBoundsCheck check = HBoundsCheck(indexArgument, length, array, type) ..sourceInformation = indexerNode.sourceInformation; block.addBefore(indexerNode, check); @@ -232,8 +231,9 @@ class IndexAssignSpecializer extends InvokeDynamicSpecializer { .isDefinitelyTrue) { needsMutableCheck = true; } else if (receiver.isArray(abstractValueDomain).isDefinitelyTrue) { - needsMutableCheck = - receiver.isModifiableArray(abstractValueDomain).isPotentiallyFalse; + needsMutableCheck = receiver + .isModifiableArray(abstractValueDomain) + .isPotentiallyFalse; } else { if (receiver.isMutableIndexable(abstractValueDomain).isPotentiallyFalse) { return null; diff --git a/pkg/compiler/lib/src/ssa/locals_handler.dart b/pkg/compiler/lib/src/ssa/locals_handler.dart index bc219935dd7..334c221cd80 100644 --- a/pkg/compiler/lib/src/ssa/locals_handler.dart +++ b/pkg/compiler/lib/src/ssa/locals_handler.dart @@ -392,10 +392,9 @@ class LocalsHandler { HInstruction receiver = readLocal( closureData.getClosureEntity(_localsMap!)!, ); - AbstractValue type = - local is BoxLocal - ? _abstractValueDomain.nonNullType - : getTypeOfCapturedVariable(redirect); + AbstractValue type = local is BoxLocal + ? _abstractValueDomain.nonNullType + : getTypeOfCapturedVariable(redirect); HInstruction fieldGet = HFieldGet( redirect, receiver, diff --git a/pkg/compiler/lib/src/ssa/nodes.dart b/pkg/compiler/lib/src/ssa/nodes.dart index c703ec08cbe..8173c5fd56c 100644 --- a/pkg/compiler/lib/src/ssa/nodes.dart +++ b/pkg/compiler/lib/src/ssa/nodes.dart @@ -1935,10 +1935,9 @@ abstract class HInvokeDynamic extends HInvoke implements InstructionContext { AbstractValue resultType, ) : _selector = selector, _originalReceiverType = _receiverType, - specializer = - isIntercepted - ? InvokeDynamicSpecializer.lookupSpecializer(selector) - : const InvokeDynamicSpecializer(), + specializer = isIntercepted + ? InvokeDynamicSpecializer.lookupSpecializer(selector) + : const InvokeDynamicSpecializer(), super(inputs, resultType) { isInterceptedCall = isIntercepted; } @@ -2100,10 +2099,9 @@ class HInvokeDynamicGetter extends HInvokeDynamicField { // There might be an interceptor input, so `inputs.last` is the dart receiver. @override - bool canThrow(AbstractValueDomain domain) => - isTearOff - ? inputs.last.isNull(domain).isPotentiallyTrue - : super.canThrow(domain); + bool canThrow(AbstractValueDomain domain) => isTearOff + ? inputs.last.isNull(domain).isPotentiallyTrue + : super.canThrow(domain); @override String toString() => diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart index 72e77adf6bf..97494c1c692 100644 --- a/pkg/compiler/lib/src/ssa/optimize.dart +++ b/pkg/compiler/lib/src/ssa/optimize.dart @@ -95,10 +95,9 @@ class SsaOptimizerTask extends CompilerTask { OptimizationTestLog? log; if (retainDataForTesting) { - log = - loggersForTesting[member] = OptimizationTestLog( - closedWorld.dartTypes, - ); + log = loggersForTesting[member] = OptimizationTestLog( + closedWorld.dartTypes, + ); } measure(() { @@ -478,10 +477,9 @@ class SsaInstructionSimplifier extends HBaseVisitor // condition ? false : true --> !condition if (_isBoolConstant(left, false) && _isBoolConstant(right, true)) { - HInstruction replacement = - HNot(condition, _abstractValueDomain.boolType) - ..sourceElement = phi.sourceElement - ..sourceInformation = phi.sourceInformation; + HInstruction replacement = HNot(condition, _abstractValueDomain.boolType) + ..sourceElement = phi.sourceElement + ..sourceInformation = phi.sourceInformation; block.addAtEntry(replacement); block.rewrite(phi, replacement); block.removePhi(phi); @@ -614,10 +612,9 @@ class SsaInstructionSimplifier extends HBaseVisitor _abstractValueDomain.boolType, ); block.addAtEntry(compare); - HInstruction replacement = - HNot(compare, _abstractValueDomain.boolType) - ..sourceElement = phi.sourceElement - ..sourceInformation = phi.sourceInformation; + HInstruction replacement = HNot(compare, _abstractValueDomain.boolType) + ..sourceElement = phi.sourceElement + ..sourceInformation = phi.sourceInformation; block.rewrite(phi, replacement); block.addAfter(compare, replacement); block.removePhi(phi); @@ -1222,13 +1219,12 @@ class SsaInstructionSimplifier extends HBaseVisitor final name = PublicName( _nativeData.computeUnescapedJSInteropName(method.name!), ); - final selector = - method.isGetter - ? Selector.getter(name) - : Selector.call( - name, - CallStructure.unnamed(invocation.inputs.length), - ); + final selector = method.isGetter + ? Selector.getter(name) + : Selector.call( + name, + CallStructure.unnamed(invocation.inputs.length), + ); if (_nativeData.interopNullChecks.containsKey(selector)) { FunctionType type = _closedWorld.elementEnvironment.getFunctionType( method, @@ -2083,11 +2079,10 @@ class SsaInstructionSimplifier extends HBaseVisitor HInstruction receiver = node.getDartReceiver(_closedWorld); AbstractValue receiverType = receiver.instructionType; - final member = - node.element ??= _closedWorld.locateSingleMember( - node.selector, - receiverType, - ); + final member = node.element ??= _closedWorld.locateSingleMember( + node.selector, + receiverType, + ); if (member == null) return node; if (member is FieldEntity) { @@ -2906,10 +2901,9 @@ class SsaInstructionSimplifier extends HBaseVisitor if (shiftedMask is IntConstantValue && shiftedMask.isUInt32()) { // TODO(sra): The shift type should be available from the abstract // value domain. - AbstractValue shiftType = - shiftedMask.isZero - ? _abstractValueDomain.uint32Type - : _abstractValueDomain.uint31Type; + AbstractValue shiftType = shiftedMask.isZero + ? _abstractValueDomain.uint32Type + : _abstractValueDomain.uint31Type; var shift = HShiftRight(operand, count, shiftType) ..sourceInformation = node.sourceInformation; @@ -3176,10 +3170,9 @@ class SsaDeadCodeEliminator extends HGraphVisitor implements OptimizationPhase { // We also leave HIf nodes in place when one branch is dead. HInstruction condition = current.inputs.first; if (condition is HConstant) { - successor = - condition.constant is TrueConstantValue - ? current.thenBlock - : current.elseBlock; + successor = condition.constant is TrueConstantValue + ? current.thenBlock + : current.elseBlock; assert(successor.isLive); } } @@ -3459,8 +3452,9 @@ class SsaDeadCodeEliminator extends HGraphVisitor implements OptimizationPhase { if (branch is HIf) { if (branch.thenBlock.isLive == branch.elseBlock.isLive) return; assert(branch.condition is HConstant); - HBasicBlock liveSuccessor = - branch.thenBlock.isLive ? branch.thenBlock : branch.elseBlock; + HBasicBlock liveSuccessor = branch.thenBlock.isLive + ? branch.thenBlock + : branch.elseBlock; HInstruction instruction = liveSuccessor.first!; // Move instructions up until the final control flow instruction or pinned // HTypeKnown. @@ -3912,10 +3906,10 @@ class SsaGlobalValueNumberer implements OptimizationPhase { // Propagate loop changes flags upwards. final parentLoopHeader = block.parentLoopHeader; if (parentLoopHeader != null) { - loopChangesFlags[parentLoopHeader - .id] = loopChangesFlags[parentLoopHeader.id].union( - (block.isLoopHeader()) ? loopChangesFlags[id] : changesFlags, - ); + loopChangesFlags[parentLoopHeader.id] = + loopChangesFlags[parentLoopHeader.id].union( + (block.isLoopHeader()) ? loopChangesFlags[id] : changesFlags, + ); } } } diff --git a/pkg/compiler/lib/src/ssa/ssa.dart b/pkg/compiler/lib/src/ssa/ssa.dart index 01959eb6f84..dd96bffdec2 100644 --- a/pkg/compiler/lib/src/ssa/ssa.dart +++ b/pkg/compiler/lib/src/ssa/ssa.dart @@ -90,10 +90,9 @@ class SsaFunctionCompiler implements FunctionCompiler { // for the target function but stubs are so simple that this usually doesn't // produce better code. Deserializing inference results is also expensive so // we avoid it here. - final inferenceResults = - member is JParameterStub - ? _trivialInferenceResults - : _globalInferenceResults; + final inferenceResults = member is JParameterStub + ? _trivialInferenceResults + : _globalInferenceResults; JClosedWorld closedWorld = _globalInferenceResults.closedWorld; CodegenRegistry registry = CodegenRegistry( diff --git a/pkg/compiler/lib/src/ssa/tracer.dart b/pkg/compiler/lib/src/ssa/tracer.dart index 3d49afa38c6..05742785d25 100644 --- a/pkg/compiler/lib/src/ssa/tracer.dart +++ b/pkg/compiler/lib/src/ssa/tracer.dart @@ -155,10 +155,9 @@ class HInstructionStringifier implements HVisitor { AbstractValueDomain get _abstractValueDomain => closedWorld.abstractValueDomain; - String visit(HInstruction node) => - node is HControlFlow - ? node.accept(this) - : '${node.accept(this)} ${node.instructionType}'; + String visit(HInstruction node) => node is HControlFlow + ? node.accept(this) + : '${node.accept(this)} ${node.instructionType}'; String temporaryId(HInstruction instruction) { String prefix; diff --git a/pkg/compiler/lib/src/ssa/type_builder.dart b/pkg/compiler/lib/src/ssa/type_builder.dart index 74e2cd5aa2d..e69b6c7e8c9 100644 --- a/pkg/compiler/lib/src/ssa/type_builder.dart +++ b/pkg/compiler/lib/src/ssa/type_builder.dart @@ -36,10 +36,9 @@ abstract class TypeBuilder { if (type is! InterfaceType) return null; // The type element is either a class or the void element. ClassEntity element = type.element; - AbstractValue mask = - includeNull - ? _abstractValueDomain.createNullableSubtype(element) - : _abstractValueDomain.createNonNullSubtype(element); + AbstractValue mask = includeNull + ? _abstractValueDomain.createNullableSubtype(element) + : _abstractValueDomain.createNonNullSubtype(element); if (hasLateSentinel) mask = _abstractValueDomain.includeLateSentinel(mask); return mask; } @@ -52,10 +51,9 @@ abstract class TypeBuilder { /// Create an instruction to simply trust the provided type. HInstruction _trustType(HInstruction original, DartType type) { - bool hasLateSentinel = - _abstractValueDomain - .isLateSentinel(original.instructionType) - .isPotentiallyTrue; + bool hasLateSentinel = _abstractValueDomain + .isLateSentinel(original.instructionType) + .isPotentiallyTrue; final mask = trustTypeMask(type, hasLateSentinel: hasLateSentinel); if (mask == null) return original; return HTypeKnown.pinned(mask, original); diff --git a/pkg/compiler/lib/src/ssa/types_propagation.dart b/pkg/compiler/lib/src/ssa/types_propagation.dart index cfcb6002907..f6692b93f7a 100644 --- a/pkg/compiler/lib/src/ssa/types_propagation.dart +++ b/pkg/compiler/lib/src/ssa/types_propagation.dart @@ -273,8 +273,9 @@ class SsaTypePropagator extends HBaseVisitor PrimitiveCheckKind kind, DartType typeExpression, ) { - Selector? selector = - (kind == PrimitiveCheckKind.receiverType) ? instruction.selector : null; + Selector? selector = (kind == PrimitiveCheckKind.receiverType) + ? instruction.selector + : null; HPrimitiveCheck converted = HPrimitiveCheck( typeExpression, kind, @@ -373,8 +374,8 @@ class SsaTypePropagator extends HBaseVisitor } AbstractValue type = right.isIntegerOrNull(abstractValueDomain).isDefinitelyTrue - ? abstractValueDomain.excludeNull(right.instructionType) - : abstractValueDomain.numType; + ? abstractValueDomain.excludeNull(right.instructionType) + : abstractValueDomain.numType; // TODO(ngeoffray): Some number operations don't have a builtin // variant and will do the check in their method anyway. We // still add a check because it allows to GVN these operations, diff --git a/pkg/compiler/lib/src/ssa/value_range_analyzer.dart b/pkg/compiler/lib/src/ssa/value_range_analyzer.dart index c63a6874123..7779e419434 100644 --- a/pkg/compiler/lib/src/ssa/value_range_analyzer.dart +++ b/pkg/compiler/lib/src/ssa/value_range_analyzer.dart @@ -885,10 +885,9 @@ class SsaValueRangeAnalyzer extends HBaseVisitor constantNum = IntConstantValue(BigInt.zero); } - BigInt intValue = - constantNum is IntConstantValue - ? constantNum.intValue - : BigInt.from(constantNum.doubleValue.toInt()); + BigInt intValue = constantNum is IntConstantValue + ? constantNum.intValue + : BigInt.from(constantNum.doubleValue.toInt()); Value value = info.newIntValue(intValue); return info.newNormalizedRange(value, value); } @@ -1309,8 +1308,9 @@ class SsaValueRangeAnalyzer extends HBaseVisitor if (node.falseBranch.predecessors.length == 1) { assert(node.falseBranch.predecessors[0] == node.block); constant_system.BinaryOperation reverse = negateOperation(operation); - constant_system.BinaryOperation reversedMirror = - flipOperation(reverse)!; + constant_system.BinaryOperation reversedMirror = flipOperation( + reverse, + )!; // Update the false branch to use narrower ranges for [left] and // [right]. Range range = computeConstrainedRange(reverse, leftRange, rightRange); @@ -1359,10 +1359,9 @@ class LoopUpdateRecognizer extends HBaseVisitor { Range? run(HPhi loopPhi) { // Create a marker range for the loop phi. This is the symbolic initial // value of the loop variable for one iteration. - bool isPositive = - loopPhi - .isPositiveInteger(closedWorld.abstractValueDomain) - .isDefinitelyTrue; + bool isPositive = loopPhi + .isPositiveInteger(closedWorld.abstractValueDomain) + .isDefinitelyTrue; final lowerMarker = info.newMarkerValue( isLower: true, isPositive: isPositive, @@ -1390,10 +1389,12 @@ class LoopUpdateRecognizer extends HBaseVisitor { Value lowerLimit = isPositive ? info.intZero : info.minIntValue; Value upperLimit = info.maxIntValue; - Value lowerBound = - deltaRange.lower == lowerMarker ? startRange.lower : lowerLimit; - Value upperBound = - deltaRange.upper == upperMarker ? startRange.upper : upperLimit; + Value lowerBound = deltaRange.lower == lowerMarker + ? startRange.lower + : lowerLimit; + Value upperBound = deltaRange.upper == upperMarker + ? startRange.upper + : upperLimit; // Widen the update range and union with the start range. final widened = updateRange.replaceMarkers(lowerBound, upperBound); diff --git a/pkg/compiler/lib/src/universe/call_structure.dart b/pkg/compiler/lib/src/universe/call_structure.dart index 0270214815a..17f80791265 100644 --- a/pkg/compiler/lib/src/universe/call_structure.dart +++ b/pkg/compiler/lib/src/universe/call_structure.dart @@ -135,10 +135,9 @@ class CallStructure { /// The names of the named arguments in canonicalized order. List getOrderedNamedArguments() => const []; - CallStructure get nonGeneric => - typeArgumentCount == 0 - ? this - : CallStructure(argumentCount, namedArguments); + CallStructure get nonGeneric => typeArgumentCount == 0 + ? this + : CallStructure(argumentCount, namedArguments); /// Short textual representation use for testing. String get shortText { @@ -287,15 +286,14 @@ class _NamedCallStructure extends CallStructure { identical(namedArguments, getOrderedNamedArguments()); @override - CallStructure toNormalized() => - isNormalized - ? this - : _NamedCallStructure( - argumentCount, - getOrderedNamedArguments(), - typeArgumentCount, - getOrderedNamedArguments(), - ); + CallStructure toNormalized() => isNormalized + ? this + : _NamedCallStructure( + argumentCount, + getOrderedNamedArguments(), + typeArgumentCount, + getOrderedNamedArguments(), + ); @override List getOrderedNamedArguments() { diff --git a/pkg/compiler/lib/src/universe/class_hierarchy.dart b/pkg/compiler/lib/src/universe/class_hierarchy.dart index 2a10c63a3c6..06834243e80 100644 --- a/pkg/compiler/lib/src/universe/class_hierarchy.dart +++ b/pkg/compiler/lib/src/universe/class_hierarchy.dart @@ -811,8 +811,8 @@ class ClassHierarchyBuilder { {}; bool isInheritedInSubtypeOf(ClassEntity x, ClassEntity y) { - _InheritedInSubtypeCache cache = - _inheritedInSubtypeCacheMap[x] ??= _InheritedInSubtypeCache(); + _InheritedInSubtypeCache cache = _inheritedInSubtypeCacheMap[x] ??= + _InheritedInSubtypeCache(); return cache.isInheritedInSubtypeOf(this, x, y); } } @@ -839,12 +839,11 @@ class _InheritedInThisClassCache { } else { set = _map![thisClass]; } - set ??= - _map![thisClass] = _computeInheritingInThisClassSet( - builder, - memberHoldingClass, - thisClass, - ); + set ??= _map![thisClass] = _computeInheritingInThisClassSet( + builder, + memberHoldingClass, + thisClass, + ); return set.hasLiveClass(builder); } diff --git a/pkg/compiler/lib/src/universe/class_set.dart b/pkg/compiler/lib/src/universe/class_set.dart index 4b8cb00e746..0aca2014185 100644 --- a/pkg/compiler/lib/src/universe/class_set.dart +++ b/pkg/compiler/lib/src/universe/class_set.dart @@ -408,10 +408,10 @@ class ClassHierarchyNode { } else { dynamic subclasses = _directSubclasses; if (sorted) { - subclasses = - _directSubclasses.toList()..sort((a, b) { - return a.cls.name.compareTo(b.cls.name); - }); + subclasses = _directSubclasses.toList() + ..sort((a, b) { + return a.cls.name.compareTo(b.cls.name); + }); } bool needsComma = false; for (ClassHierarchyNode child in subclasses) { @@ -1027,10 +1027,9 @@ class SubtypesIterator implements Iterator { bool moveNext() { if (elements == null && hierarchyNodes == null) { // Initial state. Iterate through subclasses. - elements = - iterable.subtypeSet.node - .subclassesByMask(mask, strict: !includeRoot) - .iterator; + elements = iterable.subtypeSet.node + .subclassesByMask(mask, strict: !includeRoot) + .iterator; } if (elements != null && elements!.moveNext()) { return true; diff --git a/pkg/compiler/lib/src/universe/codegen_world_builder.dart b/pkg/compiler/lib/src/universe/codegen_world_builder.dart index fa9f49ff245..ef36a65c7d2 100644 --- a/pkg/compiler/lib/src/universe/codegen_world_builder.dart +++ b/pkg/compiler/lib/src/universe/codegen_world_builder.dart @@ -346,8 +346,8 @@ class CodegenWorldBuilder extends WorldBuilder { Selector selector = dynamicUse.selector; String name = selector.name; Object? constraint = dynamicUse.receiverConstraint; - Map selectors = - selectorMap[name] ??= Maplet(); + Map selectors = selectorMap[name] ??= + Maplet(); UniverseSelectorConstraints? constraints = selectors[selector] as UniverseSelectorConstraints?; if (constraints == null) { @@ -971,10 +971,9 @@ class CodegenWorldImpl implements CodegenWorld { required Map> dynamicTypeArgumentDependencies, required this.oneShotInterceptorData, }) : _parameterStubs = parameterStubs, - _reachableLazyMemberBodies = - processedEntities - .where((e) => e is JGeneratorBody || e is JConstructorBody) - .toSet(), + _reachableLazyMemberBodies = processedEntities + .where((e) => e is JGeneratorBody || e is JConstructorBody) + .toSet(), _compiledConstants = compiledConstants, _invokedNames = invokedNames, _invokedGetters = invokedGetters, @@ -1053,69 +1052,61 @@ class CodegenWorldImpl implements CodegenWorld { Iterable get genericLocalFunctions => const []; @override - late final Iterable closurizedMembers = - (() { - final result = {}; - _liveMemberUsage.forEach((MemberEntity member, MemberUsage usage) { - if ((member.isFunction || member is JGeneratorBody) && - member.isInstanceMember && - usage.hasRead) { - result.add(member as FunctionEntity); - } - }); - return result; - })(); + late final Iterable closurizedMembers = (() { + final result = {}; + _liveMemberUsage.forEach((MemberEntity member, MemberUsage usage) { + if ((member.isFunction || member is JGeneratorBody) && + member.isInstanceMember && + usage.hasRead) { + result.add(member as FunctionEntity); + } + }); + return result; + })(); @override - late final Iterable closurizedStatics = - (() { - final result = {}; - _liveMemberUsage.forEach((MemberEntity member, MemberUsage usage) { - if (member.isFunction && - (member.isStatic || member.isTopLevel) && - usage.hasRead) { - result.add(member as FunctionEntity); - } - }); - return result; - })(); + late final Iterable closurizedStatics = (() { + final result = {}; + _liveMemberUsage.forEach((MemberEntity member, MemberUsage usage) { + if (member.isFunction && + (member.isStatic || member.isTopLevel) && + usage.hasRead) { + result.add(member as FunctionEntity); + } + }); + return result; + })(); @override - late final Map genericCallableProperties = - (() { - final result = {}; - _liveMemberUsage.forEach((MemberEntity member, MemberUsage usage) { - if (usage.hasRead) { - DartType? type; - if (member is FieldEntity) { - type = _closedWorld.elementEnvironment.getFieldType(member); - } else if (member.isGetter) { - type = - _closedWorld.elementEnvironment - .getFunctionType(member as FunctionEntity) - .returnType; - } - if (type == null) return; - if (_closedWorld.dartTypes.canAssignGenericFunctionTo(type)) { - result[member] = type; - } else { - type = type.withoutNullability; - if (type is InterfaceType) { - FunctionType? callType = _closedWorld.dartTypes.getCallType( - type, - ); - if (callType != null && - _closedWorld.dartTypes.canAssignGenericFunctionTo( - callType, - )) { - result[member] = callType; - } - } + late final Map genericCallableProperties = (() { + final result = {}; + _liveMemberUsage.forEach((MemberEntity member, MemberUsage usage) { + if (usage.hasRead) { + DartType? type; + if (member is FieldEntity) { + type = _closedWorld.elementEnvironment.getFieldType(member); + } else if (member.isGetter) { + type = _closedWorld.elementEnvironment + .getFunctionType(member as FunctionEntity) + .returnType; + } + if (type == null) return; + if (_closedWorld.dartTypes.canAssignGenericFunctionTo(type)) { + result[member] = type; + } else { + type = type.withoutNullability; + if (type is InterfaceType) { + FunctionType? callType = _closedWorld.dartTypes.getCallType(type); + if (callType != null && + _closedWorld.dartTypes.canAssignGenericFunctionTo(callType)) { + result[member] = callType; } } - }); - return result; - })(); + } + } + }); + return result; + })(); @override void forEachStaticTypeArgument( diff --git a/pkg/compiler/lib/src/universe/function_set.dart b/pkg/compiler/lib/src/universe/function_set.dart index 2e24979db4f..54e73c10b65 100644 --- a/pkg/compiler/lib/src/universe/function_set.dart +++ b/pkg/compiler/lib/src/universe/function_set.dart @@ -235,11 +235,9 @@ class FunctionSetNode { functions.addAll(noSuchMethodQuery.functions); } } - cache[selectorMask] = - result = - (functions != null) - ? FullFunctionSetQuery(functions) - : const EmptyFunctionSetQuery(); + cache[selectorMask] = result = (functions != null) + ? FullFunctionSetQuery(functions) + : const EmptyFunctionSetQuery(); return result; } diff --git a/pkg/compiler/lib/src/universe/member_hierarchy.dart b/pkg/compiler/lib/src/universe/member_hierarchy.dart index 0e39572bca3..50b293c9842 100644 --- a/pkg/compiler/lib/src/universe/member_hierarchy.dart +++ b/pkg/compiler/lib/src/universe/member_hierarchy.dart @@ -351,14 +351,13 @@ class MemberHierarchyBuilder { } } - final result = - needsNoSuchMethod - ? Setlet.of( - targetsForReceiver.followedBy( - rootsForCall(receiverType, Selectors.noSuchMethod_), - ), - ) - : targetsForReceiver; + final result = needsNoSuchMethod + ? Setlet.of( + targetsForReceiver.followedBy( + rootsForCall(receiverType, Selectors.noSuchMethod_), + ), + ) + : targetsForReceiver; return _callCache[selectorMask] = result; } @@ -496,26 +495,23 @@ class MemberHierarchyBuilder { final allMembers = closedWorld.liveInstanceMembers.followedBy( closedWorld.liveAbstractInstanceMembers, ); - final cls = - allMembers - .firstWhere((e) => e.enclosingClass!.name == className) - .enclosingClass!; + final cls = allMembers + .firstWhere((e) => e.enclosingClass!.name == className) + .enclosingClass!; final domain = closedWorld.abstractValueDomain; - final receiver = - nullValue - ? domain.nullType - : (nullReceiver - ? null - : (subClass + final receiver = nullValue + ? domain.nullType + : (nullReceiver + ? null + : (subClass ? domain.createNonNullSubclass(cls) : (subType - ? domain.createNonNullSubtype(cls) - : domain.createNullableExact(cls)))); + ? domain.createNonNullSubtype(cls) + : domain.createNullableExact(cls)))); final name = Name(selectorName, null); - final selector = - call != null - ? Selector.call(name, call) - : (setter ? Selector.setter(name) : Selector.getter(name)); + final selector = call != null + ? Selector.call(name, call) + : (setter ? Selector.setter(name) : Selector.getter(name)); print('Receiver: $receiver, Selector: $selector'); print('Locate members: ${closedWorld.locateMembers(selector, receiver)}'); diff --git a/pkg/compiler/lib/src/universe/member_usage.dart b/pkg/compiler/lib/src/universe/member_usage.dart index 3e064a2e373..d30f0c453f2 100644 --- a/pkg/compiler/lib/src/universe/member_usage.dart +++ b/pkg/compiler/lib/src/universe/member_usage.dart @@ -604,10 +604,9 @@ class MethodUsage extends MemberUsage { if (alreadyHasRead) { return MemberUses.none; } - final memberUses = - entity.isInstanceMember - ? MemberUses.closurizeInstanceOnly - : MemberUses.closurizeStaticOnly; + final memberUses = entity.isInstanceMember + ? MemberUses.closurizeInstanceOnly + : MemberUses.closurizeStaticOnly; final removed = _pendingUse.intersection(memberUses); _pendingUse = _pendingUse.setMinus(memberUses); return removed; @@ -616,10 +615,9 @@ class MethodUsage extends MemberUsage { _pendingUse = _pendingUse.setMinus(MemberUses.normalOnly); return removed; } else { - final memberUses = - entity.isInstanceMember - ? MemberUses.allInstance - : MemberUses.allStatic; + final memberUses = entity.isInstanceMember + ? MemberUses.allInstance + : MemberUses.allStatic; final removed = _pendingUse.intersection(memberUses); _pendingUse = _pendingUse.setMinus(memberUses); return removed; @@ -790,9 +788,9 @@ class ParameterUsage { _areAllTypeParametersProvided = _parameterStructure.typeParameters == 0; _providedPositionalParameters = _parameterStructure.positionalParameters == - _parameterStructure.requiredPositionalParameters - ? null - : 0; + _parameterStructure.requiredPositionalParameters + ? null + : 0; if (_parameterStructure.namedParameters.isNotEmpty) { _unprovidedNamedParameters = Set.from( _parameterStructure.namedParameters, @@ -869,8 +867,8 @@ class ParameterUsage { _unprovidedNamedParameters == null ? _parameterStructure.namedParameters : _parameterStructure.namedParameters - .where((n) => !_unprovidedNamedParameters!.contains(n)) - .toList(), + .where((n) => !_unprovidedNamedParameters!.contains(n)) + .toList(), _parameterStructure.requiredNamedParameters, _areAllTypeParametersProvided ? _parameterStructure.typeParameters : 0, ); diff --git a/pkg/compiler/lib/src/universe/record_shape.dart b/pkg/compiler/lib/src/universe/record_shape.dart index 4df880cfb6a..5c55f1c28cb 100644 --- a/pkg/compiler/lib/src/universe/record_shape.dart +++ b/pkg/compiler/lib/src/universe/record_shape.dart @@ -118,10 +118,9 @@ class RecordShape { return positionalFieldCount + nameIndex; } - String getterNameOfIndex(int index) => - index < positionalFieldCount - ? positionalFieldIndexToGetterName(index) - : fieldNames[index - positionalFieldCount]; + String getterNameOfIndex(int index) => index < positionalFieldCount + ? positionalFieldIndexToGetterName(index) + : fieldNames[index - positionalFieldCount]; bool nameMatchesGetter(String name) { return indexOfGetterName(name) >= 0; diff --git a/pkg/compiler/lib/src/universe/resource_identifier.dart b/pkg/compiler/lib/src/universe/resource_identifier.dart index 7f7b97305f0..ec24257d400 100644 --- a/pkg/compiler/lib/src/universe/resource_identifier.dart +++ b/pkg/compiler/lib/src/universe/resource_identifier.dart @@ -44,10 +44,9 @@ class ResourceIdentifier { Uri uri = source.readUri(); bool hasLocation = source.readBool(); - ResourceIdentifierLocation? location = - hasLocation - ? ResourceIdentifierLocation.readFromDataSource(source) - : null; + ResourceIdentifierLocation? location = hasLocation + ? ResourceIdentifierLocation.readFromDataSource(source) + : null; bool nonconstant = source.readBool(); String arguments = source.readString(); diff --git a/pkg/compiler/lib/src/universe/selector.dart b/pkg/compiler/lib/src/universe/selector.dart index 62b208ac97c..de25eb205e6 100644 --- a/pkg/compiler/lib/src/universe/selector.dart +++ b/pkg/compiler/lib/src/universe/selector.dart @@ -326,10 +326,9 @@ class Selector { /// A selector is normalized if its call structure is normalized. // TODO(johnniwinther): Use normalized selectors as much as possible, // especially where selectors are used in sets or as keys in maps. - Selector toNormalized() => - callStructure.isNormalized - ? this - : Selector(kind, memberName, callStructure.toNormalized()); + Selector toNormalized() => callStructure.isNormalized + ? this + : Selector(kind, memberName, callStructure.toNormalized()); Selector toCallSelector() => Selector.callClosureFrom(this); diff --git a/pkg/compiler/lib/src/util/enumset.dart b/pkg/compiler/lib/src/util/enumset.dart index cc04f5e093e..4906b5884b0 100644 --- a/pkg/compiler/lib/src/util/enumset.dart +++ b/pkg/compiler/lib/src/util/enumset.dart @@ -87,10 +87,10 @@ extension type const EnumSet(Bitset mask) { /// Iterable iterable = set.iterable(EnumClass.values); /// Iterable iterable(List values) => - // We may store extra data in the bits unused by the enum values, but that - // will result in iteration attempting to look up enum values out of bounds. - // We can avoid this by masking off such bits. - _EnumSetIterable(mask.bits & ((1 << values.length) - 1), values); + // We may store extra data in the bits unused by the enum values, but that + // will result in iteration attempting to look up enum values out of bounds. + // We can avoid this by masking off such bits. + _EnumSetIterable(mask.bits & ((1 << values.length) - 1), values); } class _EnumSetIterable extends IterableBase { diff --git a/pkg/compiler/lib/src/util/memory_compiler.dart b/pkg/compiler/lib/src/util/memory_compiler.dart index 5b35e9bc07c..296694afee1 100644 --- a/pkg/compiler/lib/src/util/memory_compiler.dart +++ b/pkg/compiler/lib/src/util/memory_compiler.dart @@ -75,15 +75,13 @@ api.CompilerDiagnostics createCompilerDiagnostics( }) { if (showDiagnostics) { if (diagnostics == null) { - diagnostics = - FormattingDiagnosticHandler() - ..verbose = verbose - ..registerFileProvider(provider); + diagnostics = FormattingDiagnosticHandler() + ..verbose = verbose + ..registerFileProvider(provider); } else { - var formattingHandler = - FormattingDiagnosticHandler() - ..verbose = verbose - ..registerFileProvider(provider); + var formattingHandler = FormattingDiagnosticHandler() + ..verbose = verbose + ..registerFileProvider(provider); diagnostics = MultiDiagnostics([diagnostics, formattingHandler]); } } else { @@ -130,8 +128,8 @@ Future runCompiler({ beforeRun(compiler); } bool isSuccess = await compiler.run(); - fe.InitializedCompilerState? compilerState = - kernelInitializedCompilerState = compiler.initializedCompilerState; + fe.InitializedCompilerState? compilerState = kernelInitializedCompilerState = + compiler.initializedCompilerState; return api.CompilationResult( compiler, isSuccess: isSuccess, diff --git a/pkg/compiler/lib/src/util/setlet.dart b/pkg/compiler/lib/src/util/setlet.dart index 233ae4af866..a7c3b3b6758 100644 --- a/pkg/compiler/lib/src/util/setlet.dart +++ b/pkg/compiler/lib/src/util/setlet.dart @@ -146,10 +146,9 @@ class Setlet extends SetBase { _contents[copyTo++] = null; } } else { - _contents = - {} - ..addAll((_contents as List).cast()) - ..add(element); + _contents = {} + ..addAll((_contents as List).cast()) + ..add(element); _extra = _marker; } return true; diff --git a/pkg/compiler/pubspec.yaml b/pkg/compiler/pubspec.yaml index 3b3315935d3..12d4341e498 100644 --- a/pkg/compiler/pubspec.yaml +++ b/pkg/compiler/pubspec.yaml @@ -5,7 +5,7 @@ name: compiler publish_to: none environment: - sdk: ^3.7.0 + sdk: ^3.8.0 resolution: workspace diff --git a/pkg/compiler/test/analyses/analysis_helper.dart b/pkg/compiler/test/analyses/analysis_helper.dart index 644f72fe80b..97a06123370 100644 --- a/pkg/compiler/test/analyses/analysis_helper.dart +++ b/pkg/compiler/test/analyses/analysis_helper.dart @@ -62,16 +62,15 @@ run( entryPoint: entryPoint, options: options, ); - load_kernel.Output result = - (await load_kernel.run( - load_kernel.Input( - compiler.options, - compiler.provider, - compiler.reporter, - compiler.initializedCompilerState, - false, - ), - ))!; + load_kernel.Output result = (await load_kernel.run( + load_kernel.Input( + compiler.options, + compiler.provider, + compiler.reporter, + compiler.initializedCompilerState, + false, + ), + ))!; compiler.frontendStrategy.registerLoadedLibraries( result.component, result.libraries!, diff --git a/pkg/compiler/test/closure/closure_test.dart b/pkg/compiler/test/closure/closure_test.dart index d46c26a99c9..656b9c47fa2 100644 --- a/pkg/compiler/test/closure/closure_test.dart +++ b/pkg/compiler/test/closure/closure_test.dart @@ -95,8 +95,8 @@ class ClosureIrChecker extends IrDataExtractor { ClosureRepresentationInfo? get closureRepresentationInfo => closureRepresentationInfoStack.isNotEmpty - ? closureRepresentationInfoStack.head - : null; + ? closureRepresentationInfoStack.head + : null; @override visitFunctionExpression(ir.FunctionExpression node) { diff --git a/pkg/compiler/test/closure/data/generic.dart b/pkg/compiler/test/closure/data/generic.dart index 251a15bf7ef..07791f69e7c 100644 --- a/pkg/compiler/test/closure/data/generic.dart +++ b/pkg/compiler/test/closure/data/generic.dart @@ -58,12 +58,12 @@ class Class1 { } var local2 = - /*fields=[S,this],free=[S,this],hasThis*/ - (o) { - return - /*fields=[S,this],free=[S,this],hasThis*/ - () => Map(); - }; + /*fields=[S,this],free=[S,this],hasThis*/ + (o) { + return + /*fields=[S,this],free=[S,this],hasThis*/ + () => Map(); + }; return local2(local()); } diff --git a/pkg/compiler/test/codegen/model_data/capture.dart b/pkg/compiler/test/codegen/model_data/capture.dart index 706552ab689..bedf3e1c7e0 100644 --- a/pkg/compiler/test/codegen/model_data/capture.dart +++ b/pkg/compiler/test/codegen/model_data/capture.dart @@ -4,7 +4,8 @@ /*member: method1:params=0*/ @pragma('dart2js:noInline') -method1([a]) => /*access=[a],params=0*/ () => a; +method1([a]) => /*access=[a],params=0*/ + () => a; class Class { /*member: Class.f:emitted*/ diff --git a/pkg/compiler/test/codegen/trust_type_annotations_test.dart b/pkg/compiler/test/codegen/trust_type_annotations_test.dart index 996a70cd616..fe23bb03bd2 100644 --- a/pkg/compiler/test/codegen/trust_type_annotations_test.dart +++ b/pkg/compiler/test/codegen/trust_type_annotations_test.dart @@ -64,19 +64,25 @@ void main() { var elementEnvironment = closedWorld.elementEnvironment; var domain = closedWorld.abstractValueDomain as CommonMasks; - ClassEntity classA = - elementEnvironment.lookupClass(elementEnvironment.mainLibrary!, "A")!; + ClassEntity classA = elementEnvironment.lookupClass( + elementEnvironment.mainLibrary!, + "A", + )!; checkReturn(String name, TypeMask type) { - MemberEntity element = - elementEnvironment.lookupClassMember(classA, PublicName(name))!; + MemberEntity element = elementEnvironment.lookupClassMember( + classA, + PublicName(name), + )!; var mask = results.resultOfMember(element).returnType as TypeMask; Expect.isTrue(type.containsMask(mask, domain)); } checkType(String name, TypeMask type) { - MemberEntity element = - elementEnvironment.lookupClassMember(classA, PublicName(name))!; + MemberEntity element = elementEnvironment.lookupClassMember( + classA, + PublicName(name), + )!; Expect.isTrue( type.containsMask( results.resultOfMember(element).type as TypeMask, diff --git a/pkg/compiler/test/codegen/type_inference5_test.dart b/pkg/compiler/test/codegen/type_inference5_test.dart index 2ecf769b927..4285d2cddc2 100644 --- a/pkg/compiler/test/codegen/type_inference5_test.dart +++ b/pkg/compiler/test/codegen/type_inference5_test.dart @@ -26,10 +26,9 @@ main() { Expect.isFalse(generated.contains('iae')); // Also make sure that we are not just in bailout mode without speculative // types by grepping for the integer-bailout check on argument j. - var argname = - RegExp( - r'function(?: [a-z]+)?\(([a-zA-Z0-9_]+)\)', - ).firstMatch(generated)![1]; + var argname = RegExp( + r'function(?: [a-z]+)?\(([a-zA-Z0-9_]+)\)', + ).firstMatch(generated)![1]; print(argname); RegExp regexp = RegExp(getIntTypeCheck("(i|$argname)")); Expect.isTrue(regexp.hasMatch(generated)); diff --git a/pkg/compiler/test/codegen/type_inference8_test.dart b/pkg/compiler/test/codegen/type_inference8_test.dart index 39e84a74067..85f828eca02 100644 --- a/pkg/compiler/test/codegen/type_inference8_test.dart +++ b/pkg/compiler/test/codegen/type_inference8_test.dart @@ -51,11 +51,10 @@ Future runTest1() async { JClosedWorld closedWorld = results.closedWorld; JElementEnvironment elementEnvironment = closedWorld.elementEnvironment; AbstractValueDomain commonMasks = closedWorld.abstractValueDomain; - MemberEntity element = - elementEnvironment.lookupLibraryMember( - elementEnvironment.mainLibrary!, - 'foo', - )!; + MemberEntity element = elementEnvironment.lookupLibraryMember( + elementEnvironment.mainLibrary!, + 'foo', + )!; AbstractValue mask = results.resultOfMember(element).returnType; AbstractValue falseType = ValueTypeMask( commonMasks.boolType as TypeMask, @@ -113,11 +112,10 @@ Future runTest2() async { JClosedWorld closedWorld = results.closedWorld; AbstractValueDomain commonMasks = closedWorld.abstractValueDomain; JElementEnvironment elementEnvironment = closedWorld.elementEnvironment; - MemberEntity element = - elementEnvironment.lookupLibraryMember( - elementEnvironment.mainLibrary!, - 'foo', - )!; + MemberEntity element = elementEnvironment.lookupLibraryMember( + elementEnvironment.mainLibrary!, + 'foo', + )!; AbstractValue mask = results.resultOfMember(element).returnType; // Can't infer value for foo's return type, it could be either true or false Expect.identical(commonMasks.boolType, mask); diff --git a/pkg/compiler/test/codesize/swarm/SwarmViews.dart b/pkg/compiler/test/codesize/swarm/SwarmViews.dart index 24549359010..3e675674a94 100644 --- a/pkg/compiler/test/codesize/swarm/SwarmViews.dart +++ b/pkg/compiler/test/codesize/swarm/SwarmViews.dart @@ -925,20 +925,19 @@ class SectionView extends CompositeView { // Lazy initialize the data source view. if (dataView == null) { // TODO(jacobr): use named arguments when available. - dataView = - dataSourceView = ListView( - section.feeds, - _viewFactory, - true /* scrollable */, - false /* vertical */, - null /* selectedItem */, - true /* snapToItems */, - true /* paginate */, - true /* removeClippedViews */, - false, - /* showScrollbar */ - pageState, - ); + dataView = dataSourceView = ListView( + section.feeds, + _viewFactory, + true /* scrollable */, + false /* vertical */, + null /* selectedItem */, + true /* snapToItems */, + true /* paginate */, + true /* removeClippedViews */, + false, + /* showScrollbar */ + pageState, + ); dataView.addClass("data-source-view"); addChild(dataView); diff --git a/pkg/compiler/test/codesize/swarm/Views.dart b/pkg/compiler/test/codesize/swarm/Views.dart index 069f4253d72..fa8cde11fc6 100644 --- a/pkg/compiler/test/codesize/swarm/Views.dart +++ b/pkg/compiler/test/codesize/swarm/Views.dart @@ -322,14 +322,12 @@ class GenericListView extends View { void _decelStart() { final scroll = scroller!; - num currentTarget = - scroll.verticalEnabled - ? scroll.currentTarget.y - : scroll.currentTarget.x; - num current = - scroll.verticalEnabled - ? scroll.contentOffset.y - : scroll.contentOffset.x; + num currentTarget = scroll.verticalEnabled + ? scroll.currentTarget.y + : scroll.currentTarget.x; + num current = scroll.verticalEnabled + ? scroll.contentOffset.y + : scroll.contentOffset.x; int targetIndex = _layout.getSnapIndex(currentTarget, _viewLength); if (current != currentTarget) { // The user is throwing rather than statically releasing. @@ -404,10 +402,9 @@ class GenericListView extends View { _pages.current.value = _layout.getPage(targetInterval.start, _viewLength); } if (_pages != null) { - _pages.length.value = - _data.isNotEmpty - ? _layout.getPage(_data.length - 1, _viewLength) + 1 - : 0; + _pages.length.value = _data.isNotEmpty + ? _layout.getPage(_data.length - 1, _viewLength) + 1 + : 0; } if (!_removeClippedViews) { @@ -677,8 +674,9 @@ class FixedSizeListViewLayout implements ListViewLayout { @override int getLength(int viewLength) { - int itemLength = - (_vertical ? itemViewFactory.height : itemViewFactory.width)!; + int itemLength = (_vertical + ? itemViewFactory.height + : itemViewFactory.width)!; if (viewLength == null || viewLength == 0) { return itemLength * _data.length; } else if (_paginate) { @@ -886,10 +884,9 @@ class VariableSizeListViewLayout implements ListViewLayout { if (index >= _itemOffsets.length) { int offset = _itemOffsets[_itemOffsets.length - 1]; for (int i = _itemOffsets.length; i <= index; i++) { - int length = - _vertical - ? itemViewFactory.getHeight(_data[i - 1]) - : itemViewFactory.getWidth(_data[i - 1]); + int length = _vertical + ? itemViewFactory.getHeight(_data[i - 1]) + : itemViewFactory.getWidth(_data[i - 1]); offset += length; _itemOffsets.add(offset); _lengths.add(length); diff --git a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/base/Size.dart b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/base/Size.dart index 8baa773b0b1..4359fd948c0 100644 --- a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/base/Size.dart +++ b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/base/Size.dart @@ -100,10 +100,9 @@ class Size { /// This function assumes that both Sizes contain strictly positive dimensions. /// Returns this Size object, after optional scaling. Size scaleToFit(Size target) { - num s = - aspectRatio() > target.aspectRatio() - ? target.width / width - : target.height / height; + num s = aspectRatio() > target.aspectRatio() + ? target.width / width + : target.height / height; return scale(s); } diff --git a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/layout/GridLayout.dart b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/layout/GridLayout.dart index 1e7de2e9771..5ad03c47e1f 100644 --- a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/layout/GridLayout.dart +++ b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/layout/GridLayout.dart @@ -334,13 +334,11 @@ class GridLayout extends ViewLayout { ContentSizeMode sizeMode, _BreadthAccumulator breadth, ) { - items = - items - .where( - (item) => - _hasContentSizedTracks(_getTracks(item), sizeMode, breadth), - ) - .toList(); + items = items + .where( + (item) => _hasContentSizedTracks(_getTracks(item), sizeMode, breadth), + ) + .toList(); var tracks = []; diff --git a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/Momentum.dart b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/Momentum.dart index 78d4db319af..39beaddf91b 100644 --- a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/Momentum.dart +++ b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/Momentum.dart @@ -304,23 +304,21 @@ class SingleDimensionPhysics { } if (stretchDistance != null) { if (stretchDistance * vel < 0) { - _bouncingState = - _bouncingState == BouncingState.BOUNCING_BACK - ? BouncingState.NOT_BOUNCING - : BouncingState.BOUNCING_AWAY; + _bouncingState = _bouncingState == BouncingState.BOUNCING_BACK + ? BouncingState.NOT_BOUNCING + : BouncingState.BOUNCING_AWAY; vel += stretchDistance * _PRE_BOUNCE_COEFFICIENT; } else { _bouncingState = BouncingState.BOUNCING_BACK; - vel = - stretchDistance > 0 - ? Math.max( - stretchDistance * _POST_BOUNCE_COEFFICIENT, - _MIN_STEP_VELOCITY, - ) - : Math.min( - stretchDistance * _POST_BOUNCE_COEFFICIENT, - -_MIN_STEP_VELOCITY, - ); + vel = stretchDistance > 0 + ? Math.max( + stretchDistance * _POST_BOUNCE_COEFFICIENT, + _MIN_STEP_VELOCITY, + ) + : Math.min( + stretchDistance * _POST_BOUNCE_COEFFICIENT, + -_MIN_STEP_VELOCITY, + ); } } else { _bouncingState = BouncingState.NOT_BOUNCING; diff --git a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/Scroller.dart b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/Scroller.dart index 0bd40bca4c6..5b0e3566230 100644 --- a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/Scroller.dart +++ b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/Scroller.dart @@ -417,14 +417,12 @@ class Scroller implements Draggable, MomentumDelegate { Coordinate contentStart = _contentStartOffset!; num newX = contentStart.x + _touchHandler.getDragDeltaX(); num newY = contentStart.y + _touchHandler.getDragDeltaY(); - newY = - _shouldScrollVertically() - ? _adjustValue(newY, _minPoint.y, _maxPoint.y) - : 0; - newX = - _shouldScrollHorizontally() - ? _adjustValue(newX, _minPoint.x, _maxPoint.x) - : 0; + newY = _shouldScrollVertically() + ? _adjustValue(newY, _minPoint.y, _maxPoint.y) + : 0; + newX = _shouldScrollHorizontally() + ? _adjustValue(newX, _minPoint.x, _maxPoint.x) + : 0; if (!_activeGesture) { _activeGesture = true; _dragInProgress = true; @@ -605,11 +603,11 @@ class Scroller implements Draggable, MomentumDelegate { static Function _getOffsetFunction(int scrollTechnique) { return scrollTechnique == ScrollerScrollTechnique.TRANSFORM_3D ? (el, x, y) { - FxUtil.setTranslate(el, x, y, 0); - } + FxUtil.setTranslate(el, x, y, 0); + } : (el, x, y) { - FxUtil.setLeftAndTop(el, x, y); - }; + FxUtil.setLeftAndTop(el, x, y); + }; } } diff --git a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/TouchHandler.dart b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/TouchHandler.dart index 3d0aacad5df..4877cdc0a31 100644 --- a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/TouchHandler.dart +++ b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/TouchHandler.dart @@ -132,10 +132,9 @@ class TouchHandler { num _correctVelocity(num velocity) { num absVelocity = velocity.abs(); if (absVelocity > _MAXIMUM_VELOCITY) { - absVelocity = - _recentTouchesY.length < 6 - ? _VELOCITY_FOR_INCORRECT_EVENTS - : _MAXIMUM_VELOCITY; + absVelocity = _recentTouchesY.length < 6 + ? _VELOCITY_FOR_INCORRECT_EVENTS + : _MAXIMUM_VELOCITY; } return absVelocity * (velocity < 0 ? -1 : 1); } diff --git a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/view/CompositeView.dart b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/view/CompositeView.dart index 9a897605307..518e4a944b8 100644 --- a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/view/CompositeView.dart +++ b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/view/CompositeView.dart @@ -83,10 +83,9 @@ class CompositeView extends View { } void removeChild(View view) { - childViews = - childViews.where((e) { - return view != e; - }).toList(); + childViews = childViews.where((e) { + return view != e; + }).toList(); // TODO(rnystrom): Container shouldn't be null. Remove this check. if (container != null) { view.node.remove(); diff --git a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/view/MeasureText.dart b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/view/MeasureText.dart index 4d042bfe8bc..e8d0e09cc26 100644 --- a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/view/MeasureText.dart +++ b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/view/MeasureText.dart @@ -123,8 +123,9 @@ class MeasureText { // Treat the char after the end of the string as whitespace. bool whitespace = i == len || isWhitespace(text[i]); if (whitespace && !lastWhitespace) { - num wordLength = - _context.measureText(text.substring(wordStartIndex!, i)).width!; + num wordLength = _context + .measureText(text.substring(wordStartIndex!, i)) + .width!; // TODO(jimhug): Replace the line above with this one to workaround // dartium bug - error: unimplemented code // num wordLength = (i - wordStartIndex) * 17; diff --git a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/view/PagedViews.dart b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/view/PagedViews.dart index 63d850ad6d1..5224a93c348 100644 --- a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/view/PagedViews.dart +++ b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/view/PagedViews.dart @@ -194,8 +194,8 @@ class PagedColumnView extends View { int pageLength = 1; scheduleMicrotask(() { if (_container.scrollWidth > _container.offset.width) { - pageLength = - (_container.scrollWidth / _computePageSize(_container)).ceil(); + pageLength = (_container.scrollWidth / _computePageSize(_container)) + .ceil(); } pageLength = Math.max(pageLength, 1); @@ -243,10 +243,9 @@ class PagedColumnView extends View { current < 0) { // The user is trying to throw so we want to round up to the // nearest page in the direction they are throwing. - newPageNumber = - currentTarget < current - ? currentPageNumber + 1 - : currentPageNumber - 1; + newPageNumber = currentTarget < current + ? currentPageNumber + 1 + : currentPageNumber - 1; } else { newPageNumber = pageNumber.round(); } diff --git a/pkg/compiler/test/deferred/constant_emission_test_helper.dart b/pkg/compiler/test/deferred/constant_emission_test_helper.dart index 7ecd8b6dfda..74a44a9aeb8 100644 --- a/pkg/compiler/test/deferred/constant_emission_test_helper.dart +++ b/pkg/compiler/test/deferred/constant_emission_test_helper.dart @@ -52,8 +52,10 @@ run( for (OutputUnitDescriptor descriptor in outputUnits) { LibraryEntity library = lookupLibrary(descriptor.uri); - MemberEntity member = - elementEnvironment.lookupLibraryMember(library, descriptor.member)!; + MemberEntity member = elementEnvironment.lookupLibraryMember( + library, + descriptor.member, + )!; OutputUnit outputUnit = outputUnitForMember(member); fragments[descriptor.name] = lookup.getFragment(outputUnit)!; } diff --git a/pkg/compiler/test/deferred/dont_inline_deferred_constants_test.dart b/pkg/compiler/test/deferred/dont_inline_deferred_constants_test.dart index d8df3b53bcc..0fcf18c9f32 100644 --- a/pkg/compiler/test/deferred/dont_inline_deferred_constants_test.dart +++ b/pkg/compiler/test/deferred/dont_inline_deferred_constants_test.dart @@ -28,9 +28,9 @@ void main() { // reference to it. 'ConstructedConstant(C(p=IntConstant(2)))': {'lib12'}, 'DeferredGlobalConstant(ConstructedConstant(C(p=IntConstant(2))))': - // With CFE constants, the references are inlined, so the constant - // occurs in lib12. - {'lib12'}, + // With CFE constants, the references are inlined, so the constant + // occurs in lib12. + {'lib12'}, // Test that the non-deferred constant is inlined. 'ConstructedConstant(C(p=IntConstant(5)))': {'main'}, }; diff --git a/pkg/compiler/test/deferred/emit_type_checks_test.dart b/pkg/compiler/test/deferred/emit_type_checks_test.dart index 45901b281d4..8507fa79a76 100644 --- a/pkg/compiler/test/deferred/emit_type_checks_test.dart +++ b/pkg/compiler/test/deferred/emit_type_checks_test.dart @@ -21,8 +21,10 @@ void main() { ); Compiler compiler = result.compiler!; String mainOutput = collector.getOutput('', api.OutputType.js)!; - String deferredOutput = - collector.getOutput('out_1', api.OutputType.jsPart)!; + String deferredOutput = collector.getOutput( + 'out_1', + api.OutputType.jsPart, + )!; JsBackendStrategy backendStrategy = compiler.backendStrategy; String isPrefix = backendStrategy.namerForTesting.fixedNames.operatorIsPrefix; diff --git a/pkg/compiler/test/deferred/inline_restrictions_test.dart b/pkg/compiler/test/deferred/inline_restrictions_test.dart index e6472861ef6..317d1e3681d 100644 --- a/pkg/compiler/test/deferred/inline_restrictions_test.dart +++ b/pkg/compiler/test/deferred/inline_restrictions_test.dart @@ -35,8 +35,10 @@ void main() { Expect.notEquals(ou_lib1.name, ou_lib3.name); String mainOutput = collector.getOutput("", api.OutputType.js)!; - String lib1Output = - collector.getOutput("out_${ou_lib1.name}", api.OutputType.jsPart)!; + String lib1Output = collector.getOutput( + "out_${ou_lib1.name}", + api.OutputType.jsPart, + )!; String? lib3Output = collector.getOutput( "out_${ou_lib3.name}", api.OutputType.jsPart, diff --git a/pkg/compiler/test/deferred_loading/data/regress_35311/main.dart b/pkg/compiler/test/deferred_loading/data/regress_35311/main.dart index 6560648fbd3..0e09e4d13eb 100644 --- a/pkg/compiler/test/deferred_loading/data/regress_35311/main.dart +++ b/pkg/compiler/test/deferred_loading/data/regress_35311/main.dart @@ -15,14 +15,13 @@ main() async { // inferred return-type in closures: // lib.B f1() => lib.B(); // Compile time error(see tests/web) - var f2 = /*closure_unit=main{}*/ - () => lib.B(); // no compile error, but f1 has inferred type: () -> d.B + var f2 = /*closure_unit=main{}*/ () => + lib.B(); // no compile error, but f1 has inferred type: () -> d.B // inferred type-arguments // lib.list = []; // Compile time error(see tests/web) lib.list = []; // no error, but type parameter was injected here - lib.list = - lib.list - .map(/*closure_unit=main{}*/ (x) => x!.value) - .toList(); // no Compile error, type parameter inferred on closure and map. + lib.list = lib.list + .map(/*closure_unit=main{}*/ (x) => x!.value) + .toList(); // no Compile error, type parameter inferred on closure and map. } diff --git a/pkg/compiler/test/deferred_loading/deferred_load_id_map_helper.dart b/pkg/compiler/test/deferred_loading/deferred_load_id_map_helper.dart index 62781d12243..534936a19c2 100644 --- a/pkg/compiler/test/deferred_loading/deferred_load_id_map_helper.dart +++ b/pkg/compiler/test/deferred_loading/deferred_load_id_map_helper.dart @@ -51,8 +51,8 @@ Future runTest( final testFiles = testDir.listSync(); final sourceFiles = {}; for (final testFile in testFiles) { - sourceFiles[testFile.uri.pathSegments.last] = - await (testFile as File).readAsString(); + sourceFiles[testFile.uri.pathSegments.last] = await (testFile as File) + .readAsString(); } final cfeCollector = OutputCollector(); await runCompiler( diff --git a/pkg/compiler/test/deferred_loading/deferred_loading_test_helper.dart b/pkg/compiler/test/deferred_loading/deferred_loading_test_helper.dart index 5862618017b..b2658ba94a1 100644 --- a/pkg/compiler/test/deferred_loading/deferred_loading_test_helper.dart +++ b/pkg/compiler/test/deferred_loading/deferred_loading_test_helper.dart @@ -148,12 +148,11 @@ class OutputUnitDataComputer extends DataComputer { }) { KernelFrontendStrategy frontendStrategy = compiler.frontendStrategy; ir.Library node = frontendStrategy.elementMap.getLibraryNode(library); - List preDeferredFragments = - compiler - .backendStrategy - .emitterTask - .emitter - .preDeferredFragmentsForTesting!; + List preDeferredFragments = compiler + .backendStrategy + .emitterTask + .emitter + .preDeferredFragmentsForTesting!; Map> fragmentsToLoad = compiler.backendStrategy.emitterTask.emitter.finalizedFragmentsToLoad; Set omittedOutputUnits = diff --git a/pkg/compiler/test/end_to_end/all_native_test.dart b/pkg/compiler/test/end_to_end/all_native_test.dart index dba3919dd39..4d0aaab7f28 100644 --- a/pkg/compiler/test/end_to_end/all_native_test.dart +++ b/pkg/compiler/test/end_to_end/all_native_test.dart @@ -35,12 +35,11 @@ test(List options) async { diagnosticHandler: collector, options: [Flags.verbose]..addAll(options), ); - int allNativeUsedCount = - collector.verboseInfos.where((CollectedMessage message) { - return message.text.startsWith( - 'All native types marked as used due to ', - ); - }).length; + int allNativeUsedCount = collector.verboseInfos.where(( + CollectedMessage message, + ) { + return message.text.startsWith('All native types marked as used due to '); + }).length; Expect.equals( 1, allNativeUsedCount, diff --git a/pkg/compiler/test/end_to_end/dill_loader_test.dart b/pkg/compiler/test/end_to_end/dill_loader_test.dart index fc16b72bdce..2216a28b84c 100644 --- a/pkg/compiler/test/end_to_end/dill_loader_test.dart +++ b/pkg/compiler/test/end_to_end/dill_loader_test.dart @@ -26,15 +26,14 @@ main() { DiagnosticCollector diagnostics = DiagnosticCollector(); OutputCollector output = OutputCollector(); - var options = - CompilerOptions() - ..target = Dart2jsTarget("dart2js", TargetFlags()) - ..packagesFileUri = Uri.base.resolve('.dart_tool/package_config.json') - ..additionalDills = [ - computePlatformBinariesLocation().resolve("dart2js_platform.dill"), - ] - ..setExitCodeOnProblem = true - ..verify = true; + var options = CompilerOptions() + ..target = Dart2jsTarget("dart2js", TargetFlags()) + ..packagesFileUri = Uri.base.resolve('.dart_tool/package_config.json') + ..additionalDills = [ + computePlatformBinariesLocation().resolve("dart2js_platform.dill"), + ] + ..setExitCodeOnProblem = true + ..verify = true; Uint8List kernelBinary = serializeComponent( (await kernelForProgram(uri, options))!.component!, @@ -45,16 +44,15 @@ main() { diagnosticHandler: diagnostics, outputProvider: output, ); - load_kernel.Output result = - (await load_kernel.run( - load_kernel.Input( - compiler.options, - compiler.provider, - compiler.reporter, - compiler.initializedCompilerState, - false, - ), - ))!; + load_kernel.Output result = (await load_kernel.run( + load_kernel.Input( + compiler.options, + compiler.provider, + compiler.reporter, + compiler.initializedCompilerState, + false, + ), + ))!; compiler.frontendStrategy.registerLoadedLibraries( result.component, result.libraries!, diff --git a/pkg/compiler/test/end_to_end/dump_info_test.dart b/pkg/compiler/test/end_to_end/dump_info_test.dart index 99310e087d3..61504a54f02 100644 --- a/pkg/compiler/test/end_to_end/dump_info_test.dart +++ b/pkg/compiler/test/end_to_end/dump_info_test.dart @@ -56,8 +56,9 @@ void main() { print('stderr:'); print(result.stderr); Expect.equals(0, result.exitCode); - String output1 = - File.fromUri(tmpDir.uri.resolve('without/out.js')).readAsStringSync(); + String output1 = File.fromUri( + tmpDir.uri.resolve('without/out.js'), + ).readAsStringSync(); command = dart2JsCommand([ '--out=json/out.js', @@ -76,12 +77,12 @@ void main() { print('stderr:'); print(result.stderr); Expect.equals(0, result.exitCode); - String output2 = - File.fromUri(tmpDir.uri.resolve('json/out.js')).readAsStringSync(); - String dumpInfoJson1 = - File.fromUri( - tmpDir.uri.resolve('json/out.js.info.json'), - ).readAsStringSync(); + String output2 = File.fromUri( + tmpDir.uri.resolve('json/out.js'), + ).readAsStringSync(); + String dumpInfoJson1 = File.fromUri( + tmpDir.uri.resolve('json/out.js.info.json'), + ).readAsStringSync(); print('Compare outputs...'); Expect.equals(output1, output2); @@ -104,12 +105,12 @@ void main() { print('stderr:'); print(result.stderr); Expect.equals(0, result.exitCode); - String output3 = - File.fromUri(tmpDir.uri.resolve('binary/out.js')).readAsStringSync(); - List dumpInfoBinary1 = - File.fromUri( - tmpDir.uri.resolve('binary/out.js.info.data'), - ).readAsBytesSync(); + String output3 = File.fromUri( + tmpDir.uri.resolve('binary/out.js'), + ).readAsStringSync(); + List dumpInfoBinary1 = File.fromUri( + tmpDir.uri.resolve('binary/out.js.info.data'), + ).readAsBytesSync(); print('Compare outputs...'); Expect.equals(output1, output3); @@ -231,12 +232,12 @@ void main() { print('stderr:'); print(result.stderr); Expect.equals(0, result.exitCode); - String output4 = - File.fromUri(tmpDir.uri.resolve('json/out.js')).readAsStringSync(); - String dumpInfoJson2 = - File.fromUri( - tmpDir.uri.resolve('json/out.js.info.json'), - ).readAsStringSync(); + String output4 = File.fromUri( + tmpDir.uri.resolve('json/out.js'), + ).readAsStringSync(); + String dumpInfoJson2 = File.fromUri( + tmpDir.uri.resolve('json/out.js.info.json'), + ).readAsStringSync(); command = dart2JsCommand([ '--input-dill=json/world.dill', @@ -261,12 +262,12 @@ void main() { print('stderr:'); print(result.stderr); Expect.equals(0, result.exitCode); - String output5 = - File.fromUri(tmpDir.uri.resolve('json/out.js')).readAsStringSync(); - List dumpInfoBinary2 = - File.fromUri( - tmpDir.uri.resolve('binary/out.js.info.data'), - ).readAsBytesSync(); + String output5 = File.fromUri( + tmpDir.uri.resolve('json/out.js'), + ).readAsStringSync(); + List dumpInfoBinary2 = File.fromUri( + tmpDir.uri.resolve('binary/out.js.info.data'), + ).readAsBytesSync(); print('Compare outputs...'); Expect.equals(output1, output4); diff --git a/pkg/compiler/test/end_to_end/exit_code_test.dart b/pkg/compiler/test/end_to_end/exit_code_test.dart index de03aac045f..7345bc07663 100644 --- a/pkg/compiler/test/end_to_end/exit_code_test.dart +++ b/pkg/compiler/test/end_to_end/exit_code_test.dart @@ -212,11 +212,10 @@ Future testExitCode( entry.exitFunc = exit; entry.compileFunc = compile; - List args = - List.from(options) - ..add("--libraries-spec=$sdkLibrariesSpecificationUri") - ..add("--platform-binaries=$sdkPlatformBinariesPath") - ..add("pkg/compiler/test/end_to_end/data/exit_code_helper.dart"); + List args = List.from(options) + ..add("--libraries-spec=$sdkLibrariesSpecificationUri") + ..add("--platform-binaries=$sdkPlatformBinariesPath") + ..add("pkg/compiler/test/end_to_end/data/exit_code_helper.dart"); Future result = entry.internalMain(args); return result .catchError((e, s) { diff --git a/pkg/compiler/test/end_to_end/modular_loader_test.dart b/pkg/compiler/test/end_to_end/modular_loader_test.dart index 6b4695c5c21..971a535f614 100644 --- a/pkg/compiler/test/end_to_end/modular_loader_test.dart +++ b/pkg/compiler/test/end_to_end/modular_loader_test.dart @@ -58,16 +58,15 @@ main() { diagnosticHandler: diagnostics, outputProvider: output, ); - load_kernel.Output result = - (await load_kernel.run( - load_kernel.Input( - compiler.options, - compiler.provider, - compiler.reporter, - compiler.initializedCompilerState, - false, - ), - ))!; + load_kernel.Output result = (await load_kernel.run( + load_kernel.Input( + compiler.options, + compiler.provider, + compiler.reporter, + compiler.initializedCompilerState, + false, + ), + ))!; // Make sure we trim the unused library. Expect.isFalse(result.libraries!.any((l) => l.path == '/unused0.dart')); @@ -111,13 +110,12 @@ Future compileUnit( fs .entityForUri(toTestUri('.dart_tool/package_config.json')) .writeAsStringSync('{"configVersion": 2, "packages": []}'); - var options = - CompilerOptions() - ..target = Dart2jsTarget("dart2js", TargetFlags()) - ..fileSystem = TestFileSystem(fs) - ..additionalDills = additionalDills - ..packagesFileUri = toTestUri('.dart_tool/package_config.json') - ..explicitExperimentalFlags = {ExperimentalFlag.nonNullable: true}; + var options = CompilerOptions() + ..target = Dart2jsTarget("dart2js", TargetFlags()) + ..fileSystem = TestFileSystem(fs) + ..additionalDills = additionalDills + ..packagesFileUri = toTestUri('.dart_tool/package_config.json') + ..explicitExperimentalFlags = {ExperimentalFlag.nonNullable: true}; var inputUris = inputs.map(toTestUri).toList(); var inputUriSet = inputUris.toSet(); var component = (await kernelForModule(inputUris, options)).component; diff --git a/pkg/compiler/test/end_to_end/no_platform_test.dart b/pkg/compiler/test/end_to_end/no_platform_test.dart index bb2ef5ede71..6901513be4d 100644 --- a/pkg/compiler/test/end_to_end/no_platform_test.dart +++ b/pkg/compiler/test/end_to_end/no_platform_test.dart @@ -24,21 +24,16 @@ main() { explicitExperimentalFlags: experimentalFlags, verify: true, ); - ir.Component component = - (await fe.compile( - initializedCompilerState, - false, - fe.StandardFileSystem.instance, - (fe.DiagnosticMessage message) { - message.plainTextFormatted.forEach(print); - Expect.notEquals(fe.Severity.error, message.severity); - }, - [ - Uri.base.resolve( - 'pkg/compiler/test/end_to_end/data/hello_world.dart', - ), - ], - ))!; + ir.Component component = (await fe.compile( + initializedCompilerState, + false, + fe.StandardFileSystem.instance, + (fe.DiagnosticMessage message) { + message.plainTextFormatted.forEach(print); + Expect.notEquals(fe.Severity.error, message.severity); + }, + [Uri.base.resolve('pkg/compiler/test/end_to_end/data/hello_world.dart')], + ))!; Expect.isNotNull(new ir.CoreTypes(component).futureClass); } diff --git a/pkg/compiler/test/end_to_end/output_type_test.dart b/pkg/compiler/test/end_to_end/output_type_test.dart index 64db3af7a99..8bfbc5154b6 100644 --- a/pkg/compiler/test/end_to_end/output_type_test.dart +++ b/pkg/compiler/test/end_to_end/output_type_test.dart @@ -55,36 +55,35 @@ Future test( List expectedOutput, { List groupOutputs = const [], }) async { - List options = - List.from(arguments) - ..add('--platform-binaries=$sdkPlatformBinariesPath') - ..add('--libraries-spec=$sdkLibrariesSpecificationUri'); + List options = List.from(arguments) + ..add('--platform-binaries=$sdkPlatformBinariesPath') + ..add('--libraries-spec=$sdkLibrariesSpecificationUri'); print('--------------------------------------------------------------------'); print('dart2js ${options.join(' ')}'); late TestRandomAccessFileOutputProvider outputProvider; - compileFunc = ( - CompilerOptions compilerOptions, - api.CompilerInput compilerInput, - api.CompilerDiagnostics compilerDiagnostics, - api.CompilerOutput compilerOutput, - ) async { - return oldCompileFunc( - compilerOptions, - compilerInput, - compilerDiagnostics, - outputProvider = TestRandomAccessFileOutputProvider( - compilerOutput as RandomAccessFileOutputProvider, - ), - ); - }; + compileFunc = + ( + CompilerOptions compilerOptions, + api.CompilerInput compilerInput, + api.CompilerDiagnostics compilerDiagnostics, + api.CompilerOutput compilerOutput, + ) async { + return oldCompileFunc( + compilerOptions, + compilerInput, + compilerDiagnostics, + outputProvider = TestRandomAccessFileOutputProvider( + compilerOutput as RandomAccessFileOutputProvider, + ), + ); + }; await internalMain(options); List outputs = outputProvider.outputs; for (String outputGroup in groupOutputs) { int countBefore = outputs.length; - outputs = - outputs - .where((String output) => !output.endsWith(outputGroup)) - .toList(); + outputs = outputs + .where((String output) => !output.endsWith(outputGroup)) + .toList(); Expect.notEquals( 0, countBefore - outputs.length, diff --git a/pkg/compiler/test/equivalence/id_equivalence_helper.dart b/pkg/compiler/test/equivalence/id_equivalence_helper.dart index 90bc9531eb4..e73d6d76846 100644 --- a/pkg/compiler/test/equivalence/id_equivalence_helper.dart +++ b/pkg/compiler/test/equivalence/id_equivalence_helper.dart @@ -237,10 +237,9 @@ Future?> computeData( ); } - dynamic closedWorld = - testFrontend - ? compiler.frontendClosedWorldForTesting - : compiler.backendClosedWorldForTesting; + dynamic closedWorld = testFrontend + ? compiler.frontendClosedWorldForTesting + : compiler.backendClosedWorldForTesting; ElementEnvironment elementEnvironment = closedWorld?.elementEnvironment; CommonElements commonElements = closedWorld.commonElements; @@ -248,14 +247,13 @@ Future?> computeData( // The Entity objects passed here can be from the K-world but // `compiler.backendStrategy.spanFromSpannable` does a J-world look up so // we may have to convert the entity first. - final backendEntity = - testFrontend - ? compiler - .backendClosedWorldForTesting - ?.elementMap - .kToJMembers[entity] ?? - entity - : entity; + final backendEntity = testFrontend + ? compiler + .backendClosedWorldForTesting + ?.elementMap + .kToJMembers[entity] ?? + entity + : entity; SourceSpan span = compiler.backendStrategy.spanFromSpannable( backendEntity, backendEntity, @@ -308,8 +306,9 @@ Future?> computeData( ir.Library getIrLibrary(LibraryEntity library) { KernelFrontendStrategy frontendStrategy = compiler.frontendStrategy; KernelToElementMap elementMap = frontendStrategy.elementMap; - LibraryEntity kLibrary = - elementMap.elementEnvironment.lookupLibrary(library.canonicalUri)!; + LibraryEntity kLibrary = elementMap.elementEnvironment.lookupLibrary( + library.canonicalUri, + )!; return elementMap.getLibraryNode(kLibrary); } @@ -490,8 +489,9 @@ Future checkTests( Future verifyCompiler(String test, Compiler compiler)?, }) async { if (testedConfigs.isEmpty) testedConfigs = defaultInternalConfigs; - Set testedMarkers = - testedConfigs.map((config) => config.marker).toSet(); + Set testedMarkers = testedConfigs + .map((config) => config.marker) + .toSet(); Expect.isTrue( testedConfigs.length == testedMarkers.length, "Unexpected test markers $testedMarkers. " @@ -591,20 +591,19 @@ Future> runTestForConfiguration( }) async { MemberAnnotations annotations = testData.expectedMaps[testConfiguration.marker]!; - CompiledData compiledData = - (await computeData( - testData.name, - testData.entryPoint, - testData.memorySourceFiles, - dataComputer, - options: [...options, ...testConfiguration.options], - verbose: verbose, - printCode: printCode, - testFrontend: dataComputer.testFrontend, - forUserLibrariesOnly: forUserLibrariesOnly, - globalIds: annotations.globalData.keys, - verifyCompiler: verifyCompiler, - ))!; + CompiledData compiledData = (await computeData( + testData.name, + testData.entryPoint, + testData.memorySourceFiles, + dataComputer, + options: [...options, ...testConfiguration.options], + verbose: verbose, + printCode: printCode, + testFrontend: dataComputer.testFrontend, + forUserLibrariesOnly: forUserLibrariesOnly, + globalIds: annotations.globalData.keys, + verifyCompiler: verifyCompiler, + ))!; return await checkCode( markerOptions, testConfiguration.marker, diff --git a/pkg/compiler/test/field_analysis/jfield_analysis_test.dart b/pkg/compiler/test/field_analysis/jfield_analysis_test.dart index 79c2e1dd98f..e894b9075b6 100644 --- a/pkg/compiler/test/field_analysis/jfield_analysis_test.dart +++ b/pkg/compiler/test/field_analysis/jfield_analysis_test.dart @@ -70,8 +70,8 @@ class JAllocatorAnalysisDataComputer extends DataComputer { ); } else if (fieldData.isEager) { if (fieldData.eagerCreationIndex != null) { - features[Tags.eagerCreationIndex] = - fieldData.eagerCreationIndex.toString(); + features[Tags.eagerCreationIndex] = fieldData.eagerCreationIndex + .toString(); } if (fieldData.eagerFieldDependenciesForTesting != null) { for (FieldEntity field diff --git a/pkg/compiler/test/field_analysis/kfield_analysis_test.dart b/pkg/compiler/test/field_analysis/kfield_analysis_test.dart index fcb0d640cf0..c35668262bd 100644 --- a/pkg/compiler/test/field_analysis/kfield_analysis_test.dart +++ b/pkg/compiler/test/field_analysis/kfield_analysis_test.dart @@ -65,8 +65,8 @@ class KAllocatorAnalysisDataComputer extends DataComputer { }); } } else { - StaticFieldData staticFieldData = - allocatorAnalysis.getStaticFieldDataForTesting(member as JField)!; + StaticFieldData staticFieldData = allocatorAnalysis + .getStaticFieldDataForTesting(member as JField)!; if (staticFieldData.initialValue != null) { features[Tags.initialValue] = staticFieldData.initialValue! .toStructuredText(dartTypes); diff --git a/pkg/compiler/test/generic_methods/function_type_variable_test.dart b/pkg/compiler/test/generic_methods/function_type_variable_test.dart index 8245ad2e004..7881847e099 100644 --- a/pkg/compiler/test/generic_methods/function_type_variable_test.dart +++ b/pkg/compiler/test/generic_methods/function_type_variable_test.dart @@ -55,7 +55,8 @@ main() { var env = await TypeEnvironment.create( createTypedefs( existentialTypeData, - additionalData: """ + additionalData: + """ class C1 {} class C2 {} class C3 { diff --git a/pkg/compiler/test/helpers/shared_helper.dart b/pkg/compiler/test/helpers/shared_helper.dart index 09ac440f114..ff646007fa8 100644 --- a/pkg/compiler/test/helpers/shared_helper.dart +++ b/pkg/compiler/test/helpers/shared_helper.dart @@ -245,10 +245,9 @@ class ConstantToTextVisitor sb.write(')'); } - void _unsupported(ConstantValue constant) => - throw UnsupportedError( - 'Unsupported constant value: ${constant.toStructuredText(_dartTypes)}', - ); + void _unsupported(ConstantValue constant) => throw UnsupportedError( + 'Unsupported constant value: ${constant.toStructuredText(_dartTypes)}', + ); @override void visitInterceptor(InterceptorConstantValue constant, StringBuffer sb) => diff --git a/pkg/compiler/test/impact/data/injected_cast.dart b/pkg/compiler/test/impact/data/injected_cast.dart index 10b4d29f5f9..66b95fae6d4 100644 --- a/pkg/compiler/test/impact/data/injected_cast.dart +++ b/pkg/compiler/test/impact/data/injected_cast.dart @@ -643,7 +643,8 @@ class Class7 { inst:JSUnmodifiableArray, param:A] */ - A Function(A) get f => (a) => a; + A Function(A) get f => + (a) => a; } /*member: method7: diff --git a/pkg/compiler/test/impact/data/literals.dart b/pkg/compiler/test/impact/data/literals.dart index f2b4edc16e6..02b254fb473 100644 --- a/pkg/compiler/test/impact/data/literals.dart +++ b/pkg/compiler/test/impact/data/literals.dart @@ -130,8 +130,9 @@ const complexSymbolField3 = const { override: const GenericClass.generative(), }; -const complexSymbolField = - complexSymbolField1 ? complexSymbolField2 : complexSymbolField3; +const complexSymbolField = complexSymbolField1 + ? complexSymbolField2 + : complexSymbolField3; /*member: testComplexConstSymbol:static=[Symbol.(1)],type=[inst:Symbol]*/ testComplexConstSymbol() => const Symbol(complexSymbolField as String); diff --git a/pkg/compiler/test/inference/callers_test.dart b/pkg/compiler/test/inference/callers_test.dart index 5b85adedd37..50f92ecbbe4 100644 --- a/pkg/compiler/test/inference/callers_test.dart +++ b/pkg/compiler/test/inference/callers_test.dart @@ -70,20 +70,18 @@ class CallersIrComputer extends IrDataExtractor { String? getMemberValue(MemberEntity member) { Iterable? callers = inferrer.getCallersOfForTesting(member); if (callers != null) { - List names = - callers.map((MemberEntity member) { - StringBuffer sb = StringBuffer(); - if (member.enclosingClass != null) { - sb.write(member.enclosingClass!.name); - sb.write('.'); - } - sb.write(member.name); - if (member.isSetter) { - sb.write('='); - } - return sb.toString(); - }).toList() - ..sort(); + List names = callers.map((MemberEntity member) { + StringBuffer sb = StringBuffer(); + if (member.enclosingClass != null) { + sb.write(member.enclosingClass!.name); + sb.write('.'); + } + sb.write(member.name); + if (member.isSetter) { + sb.write('='); + } + return sb.toString(); + }).toList()..sort(); return '[${names.join(',')}]'; } return null; diff --git a/pkg/compiler/test/inference/data/call_site.dart b/pkg/compiler/test/inference/data/call_site.dart index 68cad7244ad..376ab2671c1 100644 --- a/pkg/compiler/test/inference/data/call_site.dart +++ b/pkg/compiler/test/inference/data/call_site.dart @@ -124,7 +124,7 @@ class A8 { x8( /*Union([exact=JSString|powerset={I}{O}{I}], [exact=JsLinkedHashMap|powerset={N}{O}{N}], powerset: {IN}{O}{IN})*/ p, ) => - /*invoke: [exact=A8|powerset={N}{O}{N}]*/ x8("x"); + /*invoke: [exact=A8|powerset={N}{O}{N}]*/ x8("x"); } /*member: test8:[null|powerset={null}]*/ @@ -140,7 +140,7 @@ class A9 { /*Union([exact=JSString|powerset={I}{O}{I}], [exact=JSUInt31|powerset={I}{O}{N}], powerset: {I}{O}{IN})*/ p2, /*Union([exact=JSUInt31|powerset={I}{O}{N}], [exact=JsLinkedHashMap|powerset={N}{O}{N}], powerset: {IN}{O}{N})*/ p3, ) => - /*invoke: [exact=A9|powerset={N}{O}{N}]*/ x9(p1, "x", {}); + /*invoke: [exact=A9|powerset={N}{O}{N}]*/ x9(p1, "x", {}); } /*member: test9:[null|powerset={null}]*/ @@ -189,7 +189,7 @@ class A12 { /*Union([exact=JSString|powerset={I}{O}{I}], [exact=JSUInt31|powerset={I}{O}{N}], powerset: {I}{O}{IN})*/ p1, /*Union([exact=JSString|powerset={I}{O}{I}], [exact=JSUInt31|powerset={I}{O}{N}], powerset: {I}{O}{IN})*/ p2, ) => - /*invoke: [exact=A12|powerset={N}{O}{N}]*/ x12(1, 2); + /*invoke: [exact=A12|powerset={N}{O}{N}]*/ x12(1, 2); } /*member: test12:[null|powerset={null}]*/ @@ -320,7 +320,7 @@ class A19 { /*Union([exact=JSString|powerset={I}{O}{I}], [exact=JSUInt31|powerset={I}{O}{N}], powerset: {I}{O}{IN})*/ p1, /*Union([exact=JSString|powerset={I}{O}{I}], [exact=JSUInt31|powerset={I}{O}{N}], powerset: {I}{O}{IN})*/ p2, ) => - /*invoke: [subclass=A19|powerset={N}{O}{N}]*/ x19(p1, p2); + /*invoke: [subclass=A19|powerset={N}{O}{N}]*/ x19(p1, p2); } /*member: B19.:[exact=B19|powerset={N}{O}{N}]*/ diff --git a/pkg/compiler/test/inference/data/closure_tracer_28919.dart b/pkg/compiler/test/inference/data/closure_tracer_28919.dart index 6541d2e7a6a..6ad775a0f75 100644 --- a/pkg/compiler/test/inference/data/closure_tracer_28919.dart +++ b/pkg/compiler/test/inference/data/closure_tracer_28919.dart @@ -44,10 +44,9 @@ probe1methods( /*member: nonContainer:[exact=JSExtendableArray|powerset={I}{G}{M}]*/ nonContainer(/*[exact=JSUInt31|powerset={I}{O}{N}]*/ choice) { - var m = - choice /*invoke: [exact=JSUInt31|powerset={I}{O}{N}]*/ == 0 - ? [] - : ""; + var m = choice /*invoke: [exact=JSUInt31|powerset={I}{O}{N}]*/ == 0 + ? [] + : ""; if (m is! List) throw 123; // The union then filter leaves us with a non-container type. return m; diff --git a/pkg/compiler/test/inference/data/dictionary_types.dart b/pkg/compiler/test/inference/data/dictionary_types.dart index 6f2a4826caa..ccccf25d478 100644 --- a/pkg/compiler/test/inference/data/dictionary_types.dart +++ b/pkg/compiler/test/inference/data/dictionary_types.dart @@ -92,10 +92,10 @@ dynamic doubleOrNull2 = 22.2; test2() { var union = dictionaryA2 - /*Dictionary([exact=JsLinkedHashMap|powerset={N}{O}{N}], key: [exact=JSString|powerset={I}{O}{I}], value: Union(null, [exact=JSExtendableArray|powerset={I}{G}{M}], [exact=JSNumNotInt|powerset={I}{O}{N}], [exact=JSString|powerset={I}{O}{I}], [exact=JSUInt31|powerset={I}{O}{N}], powerset: {null}{I}{GO}{IMN}), map: {string: Value([exact=JSString|powerset={I}{O}{I}], value: "aString", powerset: {I}{O}{I}), int: [exact=JSUInt31|powerset={I}{O}{N}], double: [exact=JSNumNotInt|powerset={I}{O}{N}], list: Container([exact=JSExtendableArray|powerset={I}{G}{M}], element: [empty|powerset=empty], length: 0, powerset: {I}{G}{M})}, powerset: {N}{O}{N})*/ - ['foo'] - ? dictionaryA2 - : dictionaryB2; + /*Dictionary([exact=JsLinkedHashMap|powerset={N}{O}{N}], key: [exact=JSString|powerset={I}{O}{I}], value: Union(null, [exact=JSExtendableArray|powerset={I}{G}{M}], [exact=JSNumNotInt|powerset={I}{O}{N}], [exact=JSString|powerset={I}{O}{I}], [exact=JSUInt31|powerset={I}{O}{N}], powerset: {null}{I}{GO}{IMN}), map: {string: Value([exact=JSString|powerset={I}{O}{I}], value: "aString", powerset: {I}{O}{I}), int: [exact=JSUInt31|powerset={I}{O}{N}], double: [exact=JSNumNotInt|powerset={I}{O}{N}], list: Container([exact=JSExtendableArray|powerset={I}{G}{M}], element: [empty|powerset=empty], length: 0, powerset: {I}{G}{M})}, powerset: {N}{O}{N})*/ + ['foo'] + ? dictionaryA2 + : dictionaryB2; nullOrInt2 = union /*Dictionary([exact=JsLinkedHashMap|powerset={N}{O}{N}], key: [exact=JSString|powerset={I}{O}{I}], value: Union(null, [exact=JSExtendableArray|powerset={I}{G}{M}], [exact=JSNumNotInt|powerset={I}{O}{N}], [exact=JSString|powerset={I}{O}{I}], [exact=JSUInt31|powerset={I}{O}{N}], powerset: {null}{I}{GO}{IMN}), map: {int: [null|exact=JSUInt31|powerset={null}{I}{O}{N}], double: [null|exact=JSNumNotInt|powerset={null}{I}{O}{N}], string: Value([exact=JSString|powerset={I}{O}{I}], value: "aString", powerset: {I}{O}{I}), intTwo: [null|exact=JSUInt31|powerset={null}{I}{O}{N}], list: Container([exact=JSExtendableArray|powerset={I}{G}{M}], element: [empty|powerset=empty], length: 0, powerset: {I}{G}{M})}, powerset: {N}{O}{N})*/ diff --git a/pkg/compiler/test/inference/data/do.dart b/pkg/compiler/test/inference/data/do.dart index 7b9c4a1f296..9fa4c09d02a 100644 --- a/pkg/compiler/test/inference/data/do.dart +++ b/pkg/compiler/test/inference/data/do.dart @@ -33,7 +33,8 @@ simpleDo() { doNull() { var o; do { - o = o. /*invoke: [null|exact=JSString|powerset={null}{I}{O}{I}]*/ toString(); + o = o + . /*invoke: [null|exact=JSString|powerset={null}{I}{O}{I}]*/ toString(); } while (o == null); return o; } @@ -72,7 +73,8 @@ doNullFalse() { doNotNullTrue() { var o = null; do { - o = o. /*invoke: [null|exact=JSString|powerset={null}{I}{O}{I}]*/ toString(); + o = o + . /*invoke: [null|exact=JSString|powerset={null}{I}{O}{I}]*/ toString(); } while (o != null); return o; } @@ -96,7 +98,8 @@ class Class2 { /*member: _doUnion:Union(null, [exact=Class1|powerset={N}{O}{N}], [exact=Class2|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ _doUnion(/*[exact=Class1|powerset={N}{O}{N}]*/ o) { do { - o = o. /*Union(null, [exact=Class1|powerset={N}{O}{N}], [exact=Class2|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ field; + o = o + . /*Union(null, [exact=Class1|powerset={N}{O}{N}], [exact=Class2|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ field; } while (o != null); return o; } diff --git a/pkg/compiler/test/inference/data/field_type.dart b/pkg/compiler/test/inference/data/field_type.dart index 5065a41bd99..1a60e76ab4f 100644 --- a/pkg/compiler/test/inference/data/field_type.dart +++ b/pkg/compiler/test/inference/data/field_type.dart @@ -567,12 +567,11 @@ class A22 { /*update: [exact=A22|powerset={N}{O}{N}]*/ f22a = 42; /*update: [exact=A22|powerset={N}{O}{N}]*/ - f22b = /*[exact=A22|powerset={N}{O}{N}]*/ - f22a == null - ? 42 - : /*[exact=A22|powerset={N}{O}{N}]*/ f22c == null - ? 41 - : 43; + f22b = /*[exact=A22|powerset={N}{O}{N}]*/ f22a == null + ? 42 + : /*[exact=A22|powerset={N}{O}{N}]*/ f22c == null + ? 41 + : 43; /*update: [exact=A22|powerset={N}{O}{N}]*/ f22c = 'foo'; } @@ -707,8 +706,9 @@ class B26 { test26() { A26(). /*update: [exact=A26|powerset={N}{O}{N}]*/ f26 = [new B26(), A26()] - /*Container([exact=JSExtendableArray|powerset={I}{G}{M}], element: Union([exact=A26|powerset={N}{O}{N}], [exact=B26|powerset={N}{O}{N}], powerset: {N}{O}{N}), length: 2, powerset: {I}{G}{M})*/ - [0]. /*Union([exact=A26|powerset={N}{O}{N}], [exact=B26|powerset={N}{O}{N}], powerset: {N}{O}{N})*/ f26 /*invoke: [subclass=JSPositiveInt|powerset={I}{O}{N}]*/ + + /*Container([exact=JSExtendableArray|powerset={I}{G}{M}], element: Union([exact=A26|powerset={N}{O}{N}], [exact=B26|powerset={N}{O}{N}], powerset: {N}{O}{N}), length: 2, powerset: {I}{G}{M})*/ + [0] + . /*Union([exact=A26|powerset={N}{O}{N}], [exact=B26|powerset={N}{O}{N}], powerset: {N}{O}{N})*/ f26 /*invoke: [subclass=JSPositiveInt|powerset={I}{O}{N}]*/ + 42; } diff --git a/pkg/compiler/test/inference/data/for.dart b/pkg/compiler/test/inference/data/for.dart index 45346ea9d23..c98b8a263fd 100644 --- a/pkg/compiler/test/inference/data/for.dart +++ b/pkg/compiler/test/inference/data/for.dart @@ -113,7 +113,8 @@ class Class2 { _forUnion(/*[exact=Class1|powerset={N}{O}{N}]*/ o) { for ( ; - o = o. /*Union(null, [exact=Class1|powerset={N}{O}{N}], [exact=Class2|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ field; + o = o + . /*Union(null, [exact=Class1|powerset={N}{O}{N}], [exact=Class2|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ field; o != null ) {} return o; @@ -180,7 +181,8 @@ _forIsNot(/*[exact=Class5|powerset={N}{O}{N}]*/ o) { for ( ; o is! Class6; - o = o. /*Union(null, [exact=Class5|powerset={N}{O}{N}], [exact=Class6|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ field + o = o + . /*Union(null, [exact=Class5|powerset={N}{O}{N}], [exact=Class6|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ field ) {} return o; } diff --git a/pkg/compiler/test/inference/data/general.dart b/pkg/compiler/test/inference/data/general.dart index 8df53a7b9d2..37d70c46f5d 100644 --- a/pkg/compiler/test/inference/data/general.dart +++ b/pkg/compiler/test/inference/data/general.dart @@ -717,9 +717,8 @@ class A { ++ /*[subclass=A|powerset={N}{O}{N}]*/ /*update: [subclass=A|powerset={N}{O}{N}]*/ myField; /*member: A.returnInt2:[subclass=JSUInt32|powerset={I}{O}{N}]*/ - returnInt2() => /*invoke: [exact=JSUInt31|powerset={I}{O}{N}]*/ - ++this - . /*[subclass=A|powerset={N}{O}{N}]*/ /*update: [subclass=A|powerset={N}{O}{N}]*/ myField; + returnInt2() => /*invoke: [exact=JSUInt31|powerset={I}{O}{N}]*/ ++this + . /*[subclass=A|powerset={N}{O}{N}]*/ /*update: [subclass=A|powerset={N}{O}{N}]*/ myField; /*member: A.returnInt3:[subclass=JSUInt32|powerset={I}{O}{N}]*/ returnInt3() => @@ -749,7 +748,8 @@ class A { 1; /*member: A.myFactory:[subclass=Closure|powerset={N}{O}{N}]*/ - get myFactory => /*[exact=JSUInt31|powerset={I}{O}{N}]*/ () => 42; + get myFactory => /*[exact=JSUInt31|powerset={I}{O}{N}]*/ + () => 42; } class B extends A { @@ -757,9 +757,8 @@ class B extends A { B() : super.generative(); /*member: B.returnInt1:[subclass=JSUInt32|powerset={I}{O}{N}]*/ - returnInt1() => /*invoke: [exact=JSUInt31|powerset={I}{O}{N}]*/ - ++new A() - . /*[exact=A|powerset={N}{O}{N}]*/ /*update: [exact=A|powerset={N}{O}{N}]*/ myField; + returnInt1() => /*invoke: [exact=JSUInt31|powerset={I}{O}{N}]*/ ++new A() + . /*[exact=A|powerset={N}{O}{N}]*/ /*update: [exact=A|powerset={N}{O}{N}]*/ myField; /*member: B.returnInt2:[subclass=JSUInt32|powerset={I}{O}{N}]*/ returnInt2() => @@ -806,9 +805,8 @@ class C { ++ /*update: [exact=C|powerset={N}{O}{N}]*/ /*[exact=C|powerset={N}{O}{N}]*/ myField; /*member: C.returnInt2:[subclass=JSPositiveInt|powerset={I}{O}{N}]*/ - returnInt2() => /*invoke: [subclass=JSPositiveInt|powerset={I}{O}{N}]*/ - ++this - . /*[exact=C|powerset={N}{O}{N}]*/ /*update: [exact=C|powerset={N}{O}{N}]*/ myField; + returnInt2() => /*invoke: [subclass=JSPositiveInt|powerset={I}{O}{N}]*/ ++this + . /*[exact=C|powerset={N}{O}{N}]*/ /*update: [exact=C|powerset={N}{O}{N}]*/ myField; /*member: C.returnInt3:[subclass=JSPositiveInt|powerset={I}{O}{N}]*/ returnInt3() => diff --git a/pkg/compiler/test/inference/data/issue_48571.dart b/pkg/compiler/test/inference/data/issue_48571.dart index fdcd1d87581..c34a46cde34 100644 --- a/pkg/compiler/test/inference/data/issue_48571.dart +++ b/pkg/compiler/test/inference/data/issue_48571.dart @@ -17,10 +17,10 @@ bool trivial(/*[exact=JSBool|powerset={I}{O}{N}]*/ x) => true; /*member: either:Union([exact=Child1|powerset={N}{O}{N}], [exact=Child2|powerset={N}{O}{N}], powerset: {N}{O}{N})*/ Base either = DateTime.now() - . /*[exact=DateTime|powerset={N}{O}{N}]*/ millisecondsSinceEpoch /*invoke: [subclass=JSInt|powerset={I}{O}{N}]*/ > - 0 - ? Child2() - : Child1(); + . /*[exact=DateTime|powerset={N}{O}{N}]*/ millisecondsSinceEpoch /*invoke: [subclass=JSInt|powerset={I}{O}{N}]*/ > + 0 + ? Child2() + : Child1(); /*member: test1:Union(null, [exact=Child1|powerset={N}{O}{N}], [exact=Child2|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ test1() { diff --git a/pkg/compiler/test/inference/data/no_such_method.dart b/pkg/compiler/test/inference/data/no_such_method.dart index 5c232eb6128..305ed44f31a 100644 --- a/pkg/compiler/test/inference/data/no_such_method.dart +++ b/pkg/compiler/test/inference/data/no_such_method.dart @@ -113,14 +113,13 @@ class Class4 { /*prod.[exact=JSInvocationMirror|powerset={N}{O}{N}]*/ invocation, ) { - this. /*update: [exact=Class4|powerset={N}{O}{N}]*/ field = - invocation - . - /*[exact=JSInvocationMirror|powerset={N}{O}{N}]*/ - positionalArguments - . - /*[exact=JSUnmodifiableArray|powerset={I}{U}{I}]*/ - first; + this. /*update: [exact=Class4|powerset={N}{O}{N}]*/ field = invocation + . + /*[exact=JSInvocationMirror|powerset={N}{O}{N}]*/ + positionalArguments + . + /*[exact=JSUnmodifiableArray|powerset={I}{U}{I}]*/ + first; return null; } diff --git a/pkg/compiler/test/inference/data/no_such_method2.dart b/pkg/compiler/test/inference/data/no_such_method2.dart index 5948687e7dd..3f1658f82ae 100644 --- a/pkg/compiler/test/inference/data/no_such_method2.dart +++ b/pkg/compiler/test/inference/data/no_such_method2.dart @@ -44,8 +44,8 @@ dynamic a = [0]; /*member: test1:Dictionary([subclass=JsLinkedHashMap|powerset={N}{O}{N}], key: [empty|powerset=empty], value: [null|powerset={null}], map: {}, powerset: {N}{O}{N})*/ -test1() => - a. /*invoke: Union(null, [exact=D|powerset={N}{O}{N}], [subclass=B|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ foo(); +test1() => a + . /*invoke: Union(null, [exact=D|powerset={N}{O}{N}], [subclass=B|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ foo(); /*member: test2:Dictionary([subclass=JsLinkedHashMap|powerset={N}{O}{N}], key: [empty|powerset=empty], value: [null|powerset={null}], map: {}, powerset: {N}{O}{N})*/ test2() => B(). /*invoke: [exact=B|powerset={N}{O}{N}]*/ foo(); @@ -65,8 +65,8 @@ test5() { // Can hit A.noSuchMethod, D.noSuchMethod and Object.noSuchMethod. /*member: test6:Union([exact=JSNumNotInt|powerset={I}{O}{N}], [exact=JSUInt31|powerset={I}{O}{N}], powerset: {I}{O}{N})*/ -test6() => - a. /*invoke: Union(null, [exact=D|powerset={N}{O}{N}], [subclass=B|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ bar(); +test6() => a + . /*invoke: Union(null, [exact=D|powerset={N}{O}{N}], [subclass=B|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ bar(); // Can hit A.noSuchMethod. /*member: test7:[exact=JSUInt31|powerset={I}{O}{N}]*/ diff --git a/pkg/compiler/test/inference/data/non_null.dart b/pkg/compiler/test/inference/data/non_null.dart index 4c1637cb791..3fdd0c0667c 100644 --- a/pkg/compiler/test/inference/data/non_null.dart +++ b/pkg/compiler/test/inference/data/non_null.dart @@ -25,7 +25,8 @@ class Class1 { /*member: nonNullInstanceField1:[exact=JSUInt31|powerset={I}{O}{N}]*/ nonNullInstanceField1() { return Class1() - . /*[exact=Class1|powerset={N}{O}{N}]*/ /*update: [exact=Class1|powerset={N}{O}{N}]*/ field ??= 42; + . /*[exact=Class1|powerset={N}{O}{N}]*/ /*update: [exact=Class1|powerset={N}{O}{N}]*/ field ??= + 42; } /*member: Class2.:[exact=Class2|powerset={N}{O}{N}]*/ diff --git a/pkg/compiler/test/inference/data/postfix_prefix.dart b/pkg/compiler/test/inference/data/postfix_prefix.dart index 53a8a1542e9..50ffee0cef3 100644 --- a/pkg/compiler/test/inference/data/postfix_prefix.dart +++ b/pkg/compiler/test/inference/data/postfix_prefix.dart @@ -77,9 +77,8 @@ class B extends A { operator [](/*[empty|powerset=empty]*/ index) => 42; /*member: B.returnString1:Value([exact=JSString|powerset={I}{O}{I}], value: "string", powerset: {I}{O}{I})*/ - returnString1() => - super - .foo /*invoke: Value([exact=JSString|powerset={I}{O}{I}], value: "string", powerset: {I}{O}{I})*/ --; + returnString1() => super + .foo /*invoke: Value([exact=JSString|powerset={I}{O}{I}], value: "string", powerset: {I}{O}{I})*/ --; /*member: B.returnDynamic1:[empty|powerset=empty]*/ returnDynamic1() => diff --git a/pkg/compiler/test/inference/data/record_4.dart b/pkg/compiler/test/inference/data/record_4.dart index 58978de4b89..0b9d9295e2d 100644 --- a/pkg/compiler/test/inference/data/record_4.dart +++ b/pkg/compiler/test/inference/data/record_4.dart @@ -8,8 +8,8 @@ void main() { testList() { dynamic list = []; final rec = (list, 3); - final myList = - rec. /*[Record(RecordShape(2), [Container([exact=JSExtendableArray|powerset={I}{G}{M}], element: [exact=JSUInt31|powerset={I}{O}{N}], length: null, powerset: {I}{G}{M}), [exact=JSUInt31|powerset={I}{O}{N}]], powerset: {N}{O}{N})]*/ $1; + final myList = rec + . /*[Record(RecordShape(2), [Container([exact=JSExtendableArray|powerset={I}{G}{M}], element: [exact=JSUInt31|powerset={I}{O}{N}], length: null, powerset: {I}{G}{M}), [exact=JSUInt31|powerset={I}{O}{N}]], powerset: {N}{O}{N})]*/ $1; myList . /*invoke: Container([exact=JSExtendableArray|powerset={I}{G}{M}], element: [exact=JSUInt31|powerset={I}{O}{N}], length: null, powerset: {I}{G}{M})*/ add( 1, diff --git a/pkg/compiler/test/inference/data/static_type.dart b/pkg/compiler/test/inference/data/static_type.dart index abff3be6186..1c59b29403a 100644 --- a/pkg/compiler/test/inference/data/static_type.dart +++ b/pkg/compiler/test/inference/data/static_type.dart @@ -48,7 +48,8 @@ class C { /*member: C.fixedFunctionGetter:[subclass=Closure|powerset={N}{O}{N}]*/ int Function() - get fixedFunctionGetter => /*[exact=JSUInt31|powerset={I}{O}{N}]*/ () => 0; + get fixedFunctionGetter => /*[exact=JSUInt31|powerset={I}{O}{N}]*/ + () => 0; /*member: C.functionGetter:[null|subclass=Closure|powerset={null}{N}{O}{N}]*/ T Function()? get functionGetter => /*[subclass=C|powerset={N}{O}{N}]*/ diff --git a/pkg/compiler/test/inference/data/switch.dart b/pkg/compiler/test/inference/data/switch.dart index 7f44c20cd93..843abb915db 100644 --- a/pkg/compiler/test/inference/data/switch.dart +++ b/pkg/compiler/test/inference/data/switch.dart @@ -97,9 +97,8 @@ _switchWithContinue(/*[exact=JSUInt31|powerset={I}{O}{N}]*/ o) { continue label; label: case 1: - local = - local - . /*Union(null, [exact=JSString|powerset={I}{O}{I}], [exact=JSUInt31|powerset={I}{O}{N}], powerset: {null}{I}{O}{IN})*/ isEven; + local = local + . /*Union(null, [exact=JSString|powerset={I}{O}{I}], [exact=JSUInt31|powerset={I}{O}{N}], powerset: {null}{I}{O}{IN})*/ isEven; break; case 2: default: diff --git a/pkg/compiler/test/inference/data/use_static_types.dart b/pkg/compiler/test/inference/data/use_static_types.dart index 072b2b71a9c..5ce5ca9a392 100644 --- a/pkg/compiler/test/inference/data/use_static_types.dart +++ b/pkg/compiler/test/inference/data/use_static_types.dart @@ -237,38 +237,38 @@ accessSuperField3( /*member: invokeFunctionTypedInstanceMethod1:[subclass=A|powerset={N}{O}{N}]*/ invokeFunctionTypedInstanceMethod1( GenericClass /*[exact=GenericClass|powerset={N}{O}{N}]*/ c, -) => - c. /*invoke: [exact=GenericClass|powerset={N}{O}{N}]*/ functionTypedMethod()(); +) => c + . /*invoke: [exact=GenericClass|powerset={N}{O}{N}]*/ functionTypedMethod()(); /*member: invokeFunctionTypedInstanceMethod2:[exact=B|powerset={N}{O}{N}]*/ invokeFunctionTypedInstanceMethod2( GenericClass /*[exact=GenericClass|powerset={N}{O}{N}]*/ c, -) => - c. /*invoke: [exact=GenericClass|powerset={N}{O}{N}]*/ functionTypedMethod()(); +) => c + . /*invoke: [exact=GenericClass|powerset={N}{O}{N}]*/ functionTypedMethod()(); /*member: invokeFunctionTypedInstanceMethod3:[exact=C|powerset={N}{O}{N}]*/ invokeFunctionTypedInstanceMethod3( GenericClass /*[exact=GenericClass|powerset={N}{O}{N}]*/ c, -) => - c. /*invoke: [exact=GenericClass|powerset={N}{O}{N}]*/ functionTypedMethod()(); +) => c + . /*invoke: [exact=GenericClass|powerset={N}{O}{N}]*/ functionTypedMethod()(); /*member: invokeFunctionTypedInstanceGetter1:[subclass=A|powerset={N}{O}{N}]*/ invokeFunctionTypedInstanceGetter1( GenericClass /*[exact=GenericClass|powerset={N}{O}{N}]*/ c, -) => - c.functionTypedGetter /*invoke: [exact=GenericClass|powerset={N}{O}{N}]*/ (); +) => c + .functionTypedGetter /*invoke: [exact=GenericClass|powerset={N}{O}{N}]*/ (); /*member: invokeFunctionTypedInstanceGetter2:[exact=B|powerset={N}{O}{N}]*/ invokeFunctionTypedInstanceGetter2( GenericClass /*[exact=GenericClass|powerset={N}{O}{N}]*/ c, -) => - c.functionTypedGetter /*invoke: [exact=GenericClass|powerset={N}{O}{N}]*/ (); +) => c + .functionTypedGetter /*invoke: [exact=GenericClass|powerset={N}{O}{N}]*/ (); /*member: invokeFunctionTypedInstanceGetter3:[exact=C|powerset={N}{O}{N}]*/ invokeFunctionTypedInstanceGetter3( GenericClass /*[exact=GenericClass|powerset={N}{O}{N}]*/ c, -) => - c.functionTypedGetter /*invoke: [exact=GenericClass|powerset={N}{O}{N}]*/ (); +) => c + .functionTypedGetter /*invoke: [exact=GenericClass|powerset={N}{O}{N}]*/ (); /*member: invokeFunctionTypedInstanceField1:[subclass=A|powerset={N}{O}{N}]*/ invokeFunctionTypedInstanceField1( @@ -291,56 +291,56 @@ invokeFunctionTypedInstanceField3( /*member: invokeFunctionTypedSuperMethod1:[null|subclass=Object|powerset={null}{IN}{GFUO}{IMN}]*/ invokeFunctionTypedSuperMethod1( GenericSubclass /*[exact=GenericSubclass|powerset={N}{O}{N}]*/ c, -) => - c. /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superMethodInvoke(); +) => c + . /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superMethodInvoke(); /*member: invokeFunctionTypedSuperMethod2:[null|subclass=Object|powerset={null}{IN}{GFUO}{IMN}]*/ invokeFunctionTypedSuperMethod2( GenericSubclass /*[exact=GenericSubclass|powerset={N}{O}{N}]*/ c, -) => - c. /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superMethodInvoke(); +) => c + . /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superMethodInvoke(); /*member: invokeFunctionTypedSuperMethod3:[null|subclass=Object|powerset={null}{IN}{GFUO}{IMN}]*/ invokeFunctionTypedSuperMethod3( GenericSubclass /*[exact=GenericSubclass|powerset={N}{O}{N}]*/ c, -) => - c. /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superMethodInvoke(); +) => c + . /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superMethodInvoke(); /*member: invokeFunctionTypedSuperGetter1:[null|subclass=Object|powerset={null}{IN}{GFUO}{IMN}]*/ invokeFunctionTypedSuperGetter1( GenericSubclass /*[exact=GenericSubclass|powerset={N}{O}{N}]*/ c, -) => - c. /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superGetterInvoke(); +) => c + . /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superGetterInvoke(); /*member: invokeFunctionTypedSuperGetter2:[null|subclass=Object|powerset={null}{IN}{GFUO}{IMN}]*/ invokeFunctionTypedSuperGetter2( GenericSubclass /*[exact=GenericSubclass|powerset={N}{O}{N}]*/ c, -) => - c. /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superGetterInvoke(); +) => c + . /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superGetterInvoke(); /*member: invokeFunctionTypedSuperGetter3:[null|subclass=Object|powerset={null}{IN}{GFUO}{IMN}]*/ invokeFunctionTypedSuperGetter3( GenericSubclass /*[exact=GenericSubclass|powerset={N}{O}{N}]*/ c, -) => - c. /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superGetterInvoke(); +) => c + . /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superGetterInvoke(); /*member: invokeFunctionTypedSuperField1:[null|subclass=Object|powerset={null}{IN}{GFUO}{IMN}]*/ invokeFunctionTypedSuperField1( GenericSubclass /*[exact=GenericSubclass|powerset={N}{O}{N}]*/ c, -) => - c. /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superFieldInvoke(); +) => c + . /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superFieldInvoke(); /*member: invokeFunctionTypedSuperField2:[null|subclass=Object|powerset={null}{IN}{GFUO}{IMN}]*/ invokeFunctionTypedSuperField2( GenericSubclass /*[exact=GenericSubclass|powerset={N}{O}{N}]*/ c, -) => - c. /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superFieldInvoke(); +) => c + . /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superFieldInvoke(); /*member: invokeFunctionTypedSuperField3:[null|subclass=Object|powerset={null}{IN}{GFUO}{IMN}]*/ invokeFunctionTypedSuperField3( GenericSubclass /*[exact=GenericSubclass|powerset={N}{O}{N}]*/ c, -) => - c. /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superFieldInvoke(); +) => c + . /*invoke: [exact=GenericSubclass|powerset={N}{O}{N}]*/ superFieldInvoke(); /*member: invokeGenericClasses:[null|powerset={null}]*/ invokeGenericClasses() { @@ -498,40 +498,34 @@ invokeFunctionTypedGenericMethod3(C /*[exact=C|powerset={N}{O}{N}]*/ c) => functionTypedGenericMethod(c)(); /*member: invokeFunctionTypedGenericInstanceMethod1:[subclass=A|powerset={N}{O}{N}]*/ -invokeFunctionTypedGenericInstanceMethod1() => - Class() - . /*invoke: [exact=Class|powerset={N}{O}{N}]*/ functionTypedGenericMethod< - A - >(new A())(); +invokeFunctionTypedGenericInstanceMethod1() => Class() + . /*invoke: [exact=Class|powerset={N}{O}{N}]*/ functionTypedGenericMethod< + A + >(new A())(); /*member: invokeFunctionTypedGenericInstanceMethod2:[exact=B|powerset={N}{O}{N}]*/ -invokeFunctionTypedGenericInstanceMethod2() => - Class() - . /*invoke: [exact=Class|powerset={N}{O}{N}]*/ functionTypedGenericMethod< - B - >(new B())(); +invokeFunctionTypedGenericInstanceMethod2() => Class() + . /*invoke: [exact=Class|powerset={N}{O}{N}]*/ functionTypedGenericMethod< + B + >(new B())(); /*member: invokeFunctionTypedGenericInstanceMethod3:[exact=C|powerset={N}{O}{N}]*/ -invokeFunctionTypedGenericInstanceMethod3() => - Class() - . /*invoke: [exact=Class|powerset={N}{O}{N}]*/ functionTypedGenericMethod< - C - >(new C())(); +invokeFunctionTypedGenericInstanceMethod3() => Class() + . /*invoke: [exact=Class|powerset={N}{O}{N}]*/ functionTypedGenericMethod< + C + >(new C())(); /*member: invokeFunctionTypedGenericSuperMethod1:[subclass=A|powerset={N}{O}{N}]*/ -invokeFunctionTypedGenericSuperMethod1() => - Subclass() - . /*invoke: [exact=Subclass|powerset={N}{O}{N}]*/ functionTypedSuperMethod1(); +invokeFunctionTypedGenericSuperMethod1() => Subclass() + . /*invoke: [exact=Subclass|powerset={N}{O}{N}]*/ functionTypedSuperMethod1(); /*member: invokeFunctionTypedGenericSuperMethod2:[exact=B|powerset={N}{O}{N}]*/ -invokeFunctionTypedGenericSuperMethod2() => - Subclass() - . /*invoke: [exact=Subclass|powerset={N}{O}{N}]*/ functionTypedSuperMethod2(); +invokeFunctionTypedGenericSuperMethod2() => Subclass() + . /*invoke: [exact=Subclass|powerset={N}{O}{N}]*/ functionTypedSuperMethod2(); /*member: invokeFunctionTypedGenericSuperMethod3:[exact=C|powerset={N}{O}{N}]*/ -invokeFunctionTypedGenericSuperMethod3() => - Subclass() - . /*invoke: [exact=Subclass|powerset={N}{O}{N}]*/ functionTypedSuperMethod3(); +invokeFunctionTypedGenericSuperMethod3() => Subclass() + . /*invoke: [exact=Subclass|powerset={N}{O}{N}]*/ functionTypedSuperMethod3(); /*member: invokeGenericMethods:[null|powerset={null}]*/ invokeGenericMethods() { diff --git a/pkg/compiler/test/inference/data/while.dart b/pkg/compiler/test/inference/data/while.dart index 3692c5208f1..e704b6189e6 100644 --- a/pkg/compiler/test/inference/data/while.dart +++ b/pkg/compiler/test/inference/data/while.dart @@ -101,7 +101,8 @@ class Class2 { /*member: _whileUnion1:Union(null, [exact=Class1|powerset={N}{O}{N}], [exact=Class2|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ _whileUnion1(/*[exact=Class1|powerset={N}{O}{N}]*/ o) { while (o != null) { - o = o. /*Union([exact=Class1|powerset={N}{O}{N}], [exact=Class2|powerset={N}{O}{N}], powerset: {N}{O}{N})*/ field; + o = o + . /*Union([exact=Class1|powerset={N}{O}{N}], [exact=Class2|powerset={N}{O}{N}], powerset: {N}{O}{N})*/ field; } return o; } @@ -135,7 +136,8 @@ class Class4 { /*member: _whileUnion2:Union(null, [exact=Class3|powerset={N}{O}{N}], [exact=Class4|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ _whileUnion2(/*[exact=Class4|powerset={N}{O}{N}]*/ o) { while (o != null) { - o = o. /*Union([exact=Class3|powerset={N}{O}{N}], [exact=Class4|powerset={N}{O}{N}], powerset: {N}{O}{N})*/ field; + o = o + . /*Union([exact=Class3|powerset={N}{O}{N}], [exact=Class4|powerset={N}{O}{N}], powerset: {N}{O}{N})*/ field; } return o; } @@ -171,7 +173,8 @@ _whileUnion3( /*Union([exact=Class5|powerset={N}{O}{N}], [exact=Class6|powerset={N}{O}{N}], powerset: {N}{O}{N})*/ o, ) { while (o != null) { - o = o. /*Union([exact=Class5|powerset={N}{O}{N}], [exact=Class6|powerset={N}{O}{N}], powerset: {N}{O}{N})*/ field; + o = o + . /*Union([exact=Class5|powerset={N}{O}{N}], [exact=Class6|powerset={N}{O}{N}], powerset: {N}{O}{N})*/ field; } return o; } @@ -238,7 +241,8 @@ class Class10 { /*member: _whileIsNot:Union(null, [exact=Class10|powerset={N}{O}{N}], [exact=Class9|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ _whileIsNot(/*[exact=Class9|powerset={N}{O}{N}]*/ o) { while (o is! Class10) { - o = o. /*Union(null, [exact=Class10|powerset={N}{O}{N}], [exact=Class9|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ field; + o = o + . /*Union(null, [exact=Class10|powerset={N}{O}{N}], [exact=Class9|powerset={N}{O}{N}], powerset: {null}{N}{O}{N})*/ field; } return o; } diff --git a/pkg/compiler/test/inference/load_deferred_library_test.dart b/pkg/compiler/test/inference/load_deferred_library_test.dart index 202cffa73b0..ff985dcc430 100644 --- a/pkg/compiler/test/inference/load_deferred_library_test.dart +++ b/pkg/compiler/test/inference/load_deferred_library_test.dart @@ -45,8 +45,9 @@ runTest(List options, {bool trust = true}) async { JClosedWorld closedWorld = compiler.backendClosedWorldForTesting!; AbstractValueDomain abstractValueDomain = closedWorld.abstractValueDomain; ElementEnvironment elementEnvironment = closedWorld.elementEnvironment; - LibraryEntity helperLibrary = - elementEnvironment.lookupLibrary(Uris.dartJSHelper)!; + LibraryEntity helperLibrary = elementEnvironment.lookupLibrary( + Uris.dartJSHelper, + )!; final loadDeferredLibrary = elementEnvironment.lookupLibraryMember( helperLibrary, diff --git a/pkg/compiler/test/inference/record_type_test.dart b/pkg/compiler/test/inference/record_type_test.dart index fd2b96f45f6..1207e3a807b 100644 --- a/pkg/compiler/test/inference/record_type_test.dart +++ b/pkg/compiler/test/inference/record_type_test.dart @@ -141,8 +141,9 @@ main() { final shape2Class = world.recordData.representationForShape(shape2)!.cls; final shape2Mask = FlatTypeMask.nonNullExact(shape2Class, domain); final shape1Foo = RecordShape(1, ["foo"]); - final shape1FooClass = - world.recordData.representationForShape(shape1Foo)!.cls; + final shape1FooClass = world.recordData + .representationForShape(shape1Foo)! + .cls; final shape1FooMask = FlatTypeMask.nonNullExact(shape1FooClass, domain); final uninstantiatedShape = RecordShape(2, ["bar"]); diff --git a/pkg/compiler/test/inference/type_combination_test.dart b/pkg/compiler/test/inference/type_combination_test.dart index 2687de2e943..580f6311019 100644 --- a/pkg/compiler/test/inference/type_combination_test.dart +++ b/pkg/compiler/test/inference/type_combination_test.dart @@ -804,8 +804,8 @@ runTests() async { } ''', }, - beforeRun: - (compiler) => compiler.stopAfterGlobalTypeInferenceForTesting = true, + beforeRun: (compiler) => + compiler.stopAfterGlobalTypeInferenceForTesting = true, ); Expect.isTrue(result.isSuccess); Compiler compiler = result.compiler!; @@ -819,11 +819,10 @@ runTests() async { LibraryEntity coreLibrary = commonElements.coreLibrary; patternClass = elementEnvironment.lookupClass(coreLibrary, 'Pattern'); - final trustedGetRuntimeTypeInterface = - elementEnvironment.lookupClass( - commonElements.jsHelperLibrary!, - 'TrustedGetRuntimeType', - )!; + final trustedGetRuntimeTypeInterface = elementEnvironment.lookupClass( + commonElements.jsHelperLibrary!, + 'TrustedGetRuntimeType', + )!; nonPrimitive1 = TypeMask.nonNullSubtype( closedWorld.commonElements.mapClass, diff --git a/pkg/compiler/test/inference/type_mask_disjoint_test.dart b/pkg/compiler/test/inference/type_mask_disjoint_test.dart index 0f791f79dcf..af723837127 100644 --- a/pkg/compiler/test/inference/type_mask_disjoint_test.dart +++ b/pkg/compiler/test/inference/type_mask_disjoint_test.dart @@ -107,12 +107,11 @@ main() { return cls; }); - var mask = - isExact - ? TypeMask.nonNullExact(element, commonMasks) - : (isSubclass - ? TypeMask.nonNullSubclass(element, commonMasks) - : TypeMask.nonNullSubtype(element, commonMasks)); + var mask = isExact + ? TypeMask.nonNullExact(element, commonMasks) + : (isSubclass + ? TypeMask.nonNullSubclass(element, commonMasks) + : TypeMask.nonNullSubtype(element, commonMasks)); return isNullable ? mask.nullable(commonMasks) : mask; }); diff --git a/pkg/compiler/test/js/js_constant_test.dart b/pkg/compiler/test/js/js_constant_test.dart index 1d7d4093541..05ab08484ed 100644 --- a/pkg/compiler/test/js/js_constant_test.dart +++ b/pkg/compiler/test/js/js_constant_test.dart @@ -34,8 +34,9 @@ main() { var elementEnvironment = closedWorld.elementEnvironment; MemberEntity element = elementEnvironment.mainFunction!; - String generated = - compiler.backendStrategy.getGeneratedCodeForTesting(element)!; + String generated = compiler.backendStrategy.getGeneratedCodeForTesting( + element, + )!; checkerForAbsentPresent(test)(generated); } diff --git a/pkg/compiler/test/js/js_spec_optimization_test.dart b/pkg/compiler/test/js/js_spec_optimization_test.dart index 548f1473fd1..aac1fd9b856 100644 --- a/pkg/compiler/test/js/js_spec_optimization_test.dart +++ b/pkg/compiler/test/js/js_spec_optimization_test.dart @@ -101,8 +101,9 @@ main() { var elementEnvironment = closedWorld.elementEnvironment; MemberEntity element = elementEnvironment.mainFunction!; - String generated = - compiler.backendStrategy.getGeneratedCodeForTesting(element)!; + String generated = compiler.backendStrategy.getGeneratedCodeForTesting( + element, + )!; checker(generated); } diff --git a/pkg/compiler/test/jsinterop/internal_annotations_test.dart b/pkg/compiler/test/jsinterop/internal_annotations_test.dart index c9f2678e346..3b9c9c77310 100644 --- a/pkg/compiler/test/jsinterop/internal_annotations_test.dart +++ b/pkg/compiler/test/jsinterop/internal_annotations_test.dart @@ -36,7 +36,8 @@ testClasses(String import1, String import2) async { CompilationResult result = await runCompiler( entryPoint: entryPoint, memorySourceFiles: { - mainFile: """ + mainFile: + """ import '$import1' as js1; import '$import2' as js2; diff --git a/pkg/compiler/test/jsinterop/world_test.dart b/pkg/compiler/test/jsinterop/world_test.dart index 2f4a131d995..b1a62160b94 100644 --- a/pkg/compiler/test/jsinterop/world_test.dart +++ b/pkg/compiler/test/jsinterop/world_test.dart @@ -31,7 +31,8 @@ testClasses() async { }) async { CompilationResult result = await runCompiler( memorySourceFiles: { - 'main.dart': """ + 'main.dart': + """ import 'package:js/js.dart'; @JS() diff --git a/pkg/compiler/test/model/cfe_annotations_test.dart b/pkg/compiler/test/model/cfe_annotations_test.dart index 6fffba1e38f..c34627da2fa 100644 --- a/pkg/compiler/test/model/cfe_annotations_test.dart +++ b/pkg/compiler/test/model/cfe_annotations_test.dart @@ -244,8 +244,9 @@ main(List args) { List pragmaAnnotations = annotationData .getMemberPragmaAnnotationData(member); - Set pragmaNames = - pragmaAnnotations.map((d) => d.name).toSet(); + Set pragmaNames = pragmaAnnotations + .map((d) => d.name) + .toSet(); Expect.setEquals( expectedPragmaNames, pragmaNames, @@ -302,8 +303,8 @@ main(List args) { isNativeMember ? expectedNativeMemberName ?? memberEntity.name : (isJsInteropMember - ? expectedJsInteropMemberName ?? memberEntity.name - : null), + ? expectedJsInteropMemberName ?? memberEntity.name + : null), nativeData.getFixedBackendName(memberEntity), "Unexpected fixed backend name from native data for $member, " "id: $memberId", @@ -354,8 +355,9 @@ main(List args) { List pragmaAnnotations = frontendStrategy .modularStrategyForTesting .getPragmaAnnotationData(member); - Set pragmaNames = - pragmaAnnotations.map((d) => d.name).toSet(); + Set pragmaNames = pragmaAnnotations + .map((d) => d.name) + .toSet(); Expect.setEquals( expectedPragmaNames, pragmaNames, diff --git a/pkg/compiler/test/model/cfe_constant_evaluation_common.dart b/pkg/compiler/test/model/cfe_constant_evaluation_common.dart index 86199247ab9..e921f0436a2 100644 --- a/pkg/compiler/test/model/cfe_constant_evaluation_common.dart +++ b/pkg/compiler/test/model/cfe_constant_evaluation_common.dart @@ -910,10 +910,9 @@ Future runEnvTest( node.initializer!, ); - ConstantValue? value = - evaluatedConstant is! ir.UnevaluatedConstant - ? constantValuefier.visitConstant(evaluatedConstant) - : null; + ConstantValue? value = evaluatedConstant is! ir.UnevaluatedConstant + ? constantValuefier.visitConstant(evaluatedConstant) + : null; String valueText = value?.toStructuredText(dartTypes) ?? 'NonConstant'; Expect.equals( diff --git a/pkg/compiler/test/model/class_set_test.dart b/pkg/compiler/test/model/class_set_test.dart index 1bc00e8ef6a..d045374eec5 100644 --- a/pkg/compiler/test/model/class_set_test.dart +++ b/pkg/compiler/test/model/class_set_test.dart @@ -151,11 +151,10 @@ testIterators() async { } } - iterator = - ClassHierarchyNodeIterable( - world.classHierarchy.getClassHierarchyNode(G), - ClassHierarchyNode.all, - ).iterator; + iterator = ClassHierarchyNodeIterable( + world.classHierarchy.getClassHierarchyNode(G), + ClassHierarchyNode.all, + ).iterator; checkState(G, currentNode: null, stack: null); Expect.isTrue(iterator.moveNext()); checkState(G, currentNode: G, stack: []); @@ -163,21 +162,19 @@ testIterators() async { checkState(G, currentNode: null, stack: []); Expect.throws(() => iterator.current); - iterator = - ClassHierarchyNodeIterable( - world.classHierarchy.getClassHierarchyNode(G), - ClassHierarchyNode.all, - includeRoot: false, - ).iterator; + iterator = ClassHierarchyNodeIterable( + world.classHierarchy.getClassHierarchyNode(G), + ClassHierarchyNode.all, + includeRoot: false, + ).iterator; checkState(G, currentNode: null, stack: null); Expect.isFalse(iterator.moveNext()); checkState(G, currentNode: null, stack: []); - iterator = - ClassHierarchyNodeIterable( - world.classHierarchy.getClassHierarchyNode(C), - ClassHierarchyNode.all, - ).iterator; + iterator = ClassHierarchyNodeIterable( + world.classHierarchy.getClassHierarchyNode(C), + ClassHierarchyNode.all, + ).iterator; checkState(C, currentNode: null, stack: null); Expect.isTrue(iterator.moveNext()); checkState(C, currentNode: C, stack: [G, F, E]); @@ -190,22 +187,20 @@ testIterators() async { Expect.isFalse(iterator.moveNext()); checkState(C, currentNode: null, stack: []); - iterator = - ClassHierarchyNodeIterable( - world.classHierarchy.getClassHierarchyNode(D), - ClassHierarchyNode.all, - ).iterator; + iterator = ClassHierarchyNodeIterable( + world.classHierarchy.getClassHierarchyNode(D), + ClassHierarchyNode.all, + ).iterator; checkState(D, currentNode: null, stack: null); Expect.isTrue(iterator.moveNext()); checkState(D, currentNode: D, stack: []); Expect.isFalse(iterator.moveNext()); checkState(D, currentNode: null, stack: []); - iterator = - ClassHierarchyNodeIterable( - world.classHierarchy.getClassHierarchyNode(B), - ClassHierarchyNode.all, - ).iterator; + iterator = ClassHierarchyNodeIterable( + world.classHierarchy.getClassHierarchyNode(B), + ClassHierarchyNode.all, + ).iterator; checkState(B, currentNode: null, stack: null); Expect.isTrue(iterator.moveNext()); checkState(B, currentNode: B, stack: [D]); @@ -214,37 +209,34 @@ testIterators() async { Expect.isFalse(iterator.moveNext()); checkState(B, currentNode: null, stack: []); - iterator = - ClassHierarchyNodeIterable( - world.classHierarchy.getClassHierarchyNode(B), - ClassHierarchyNode.all, - includeRoot: false, - ).iterator; + iterator = ClassHierarchyNodeIterable( + world.classHierarchy.getClassHierarchyNode(B), + ClassHierarchyNode.all, + includeRoot: false, + ).iterator; checkState(B, currentNode: null, stack: null); Expect.isTrue(iterator.moveNext()); checkState(B, currentNode: D, stack: []); Expect.isFalse(iterator.moveNext()); checkState(B, currentNode: null, stack: []); - iterator = - ClassHierarchyNodeIterable( - world.classHierarchy.getClassHierarchyNode(B), - EnumSet.fromValues([ - Instantiation.directlyInstantiated, - Instantiation.uninstantiated, - ]), - ).iterator; + iterator = ClassHierarchyNodeIterable( + world.classHierarchy.getClassHierarchyNode(B), + EnumSet.fromValues([ + Instantiation.directlyInstantiated, + Instantiation.uninstantiated, + ]), + ).iterator; checkState(B, currentNode: null, stack: null); Expect.isTrue(iterator.moveNext()); checkState(B, currentNode: D, stack: []); Expect.isFalse(iterator.moveNext()); checkState(B, currentNode: null, stack: []); - iterator = - ClassHierarchyNodeIterable( - world.classHierarchy.getClassHierarchyNode(A), - ClassHierarchyNode.all, - ).iterator; + iterator = ClassHierarchyNodeIterable( + world.classHierarchy.getClassHierarchyNode(A), + ClassHierarchyNode.all, + ).iterator; checkState(A, currentNode: null, stack: null); Expect.isTrue(iterator.moveNext()); checkState(A, currentNode: A, stack: [C, B]); @@ -263,12 +255,11 @@ testIterators() async { Expect.isFalse(iterator.moveNext()); checkState(A, currentNode: null, stack: []); - iterator = - ClassHierarchyNodeIterable( - world.classHierarchy.getClassHierarchyNode(A), - ClassHierarchyNode.all, - includeRoot: false, - ).iterator; + iterator = ClassHierarchyNodeIterable( + world.classHierarchy.getClassHierarchyNode(A), + ClassHierarchyNode.all, + includeRoot: false, + ).iterator; checkState(A, currentNode: null, stack: null); Expect.isTrue(iterator.moveNext()); checkState(A, currentNode: B, stack: [C, D]); @@ -285,14 +276,13 @@ testIterators() async { Expect.isFalse(iterator.moveNext()); checkState(A, currentNode: null, stack: []); - iterator = - ClassHierarchyNodeIterable( - world.classHierarchy.getClassHierarchyNode(A), - EnumSet.fromValues([ - Instantiation.directlyInstantiated, - Instantiation.uninstantiated, - ]), - ).iterator; + iterator = ClassHierarchyNodeIterable( + world.classHierarchy.getClassHierarchyNode(A), + EnumSet.fromValues([ + Instantiation.directlyInstantiated, + Instantiation.uninstantiated, + ]), + ).iterator; checkState(A, currentNode: null, stack: null); Expect.isTrue(iterator.moveNext()); checkState(A, currentNode: A, stack: [C, B]); @@ -309,15 +299,14 @@ testIterators() async { Expect.isFalse(iterator.moveNext()); checkState(A, currentNode: null, stack: []); - iterator = - ClassHierarchyNodeIterable( - world.classHierarchy.getClassHierarchyNode(A), - EnumSet.fromValues([ - Instantiation.directlyInstantiated, - Instantiation.uninstantiated, - ]), - includeRoot: false, - ).iterator; + iterator = ClassHierarchyNodeIterable( + world.classHierarchy.getClassHierarchyNode(A), + EnumSet.fromValues([ + Instantiation.directlyInstantiated, + Instantiation.uninstantiated, + ]), + includeRoot: false, + ).iterator; checkState(A, currentNode: null, stack: null); Expect.isTrue(iterator.moveNext()); checkState(A, currentNode: D, stack: [C]); diff --git a/pkg/compiler/test/model/enqueuer_test.dart b/pkg/compiler/test/model/enqueuer_test.dart index 3f3d2fad5ef..408825950c1 100644 --- a/pkg/compiler/test/model/enqueuer_test.dart +++ b/pkg/compiler/test/model/enqueuer_test.dart @@ -172,7 +172,8 @@ Iterable> permutations(List impacts) sync* { runTestPermutation(Test test, List impacts) async { Compiler compiler = compilerFor( memorySourceFiles: { - 'main.dart': ''' + 'main.dart': + ''' ${test.code} main() {} ''', @@ -199,20 +200,24 @@ main() {} ElementEnvironment elementEnvironment, String name, ) { - ClassEntity cls = - elementEnvironment.lookupClass(elementEnvironment.mainLibrary!, name)!; - ConstructorEntity constructor = - elementEnvironment.lookupConstructor(cls, '')!; + ClassEntity cls = elementEnvironment.lookupClass( + elementEnvironment.mainLibrary!, + name, + )!; + ConstructorEntity constructor = elementEnvironment.lookupConstructor( + cls, + '', + )!; InterfaceType type = elementEnvironment.getRawType(cls); - WorldImpact impact = - WorldImpactBuilderImpl()..registerStaticUse( - new StaticUse.typedConstructorInvoke( - constructor, - constructor.parameterStructure.callStructure, - type, - null, - ), - ); + WorldImpact impact = WorldImpactBuilderImpl() + ..registerStaticUse( + new StaticUse.typedConstructorInvoke( + constructor, + constructor.parameterStructure.callStructure, + type, + null, + ), + ); enqueuer.applyImpact(impact); } @@ -223,19 +228,18 @@ main() {} String methodName, Object Function(ClassEntity cls) createConstraint, ) { - ClassEntity cls = - elementEnvironment.lookupClass( - elementEnvironment.mainLibrary!, - className, - )!; + ClassEntity cls = elementEnvironment.lookupClass( + elementEnvironment.mainLibrary!, + className, + )!; Selector selector = Selector.call( Name(methodName, elementEnvironment.mainLibrary!.canonicalUri), CallStructure.noArgs, ); - WorldImpact impact = - WorldImpactBuilderImpl()..registerDynamicUse( - DynamicUse(selector, createConstraint(cls), const []), - ); + WorldImpact impact = WorldImpactBuilderImpl() + ..registerDynamicUse( + DynamicUse(selector, createConstraint(cls), const []), + ); enqueuer.applyImpact(impact); } diff --git a/pkg/compiler/test/model/forwarding_stub_test.dart b/pkg/compiler/test/model/forwarding_stub_test.dart index c7ab2e0b270..91935bc8e80 100644 --- a/pkg/compiler/test/model/forwarding_stub_test.dart +++ b/pkg/compiler/test/model/forwarding_stub_test.dart @@ -33,16 +33,14 @@ main() { Compiler compiler = result.compiler!; JClosedWorld closedWorld = compiler.backendClosedWorldForTesting!; ElementEnvironment elementEnvironment = closedWorld.elementEnvironment; - ClassEntity cls = - elementEnvironment.lookupClass( - elementEnvironment.mainLibrary!, - 'Class', - )!; - ClassEntity mixin = - elementEnvironment.lookupClass( - elementEnvironment.mainLibrary!, - 'Mixin', - )!; + ClassEntity cls = elementEnvironment.lookupClass( + elementEnvironment.mainLibrary!, + 'Class', + )!; + ClassEntity mixin = elementEnvironment.lookupClass( + elementEnvironment.mainLibrary!, + 'Mixin', + )!; final method = elementEnvironment.lookupClassMember( cls, PublicName('method'), diff --git a/pkg/compiler/test/model/mixin_typevariable_test.dart b/pkg/compiler/test/model/mixin_typevariable_test.dart index 6bee196f0b5..b7ed8e9a7cd 100644 --- a/pkg/compiler/test/model/mixin_typevariable_test.dart +++ b/pkg/compiler/test/model/mixin_typevariable_test.dart @@ -197,11 +197,10 @@ testNonTrivialSubstitutions() async { instantiate(types, A, [D1_T]), ], }); - DartType D1_superclass_T = - env.elementEnvironment - .getThisType(env.elementEnvironment.getSuperClass(D1)!) - .typeArguments - .first; + DartType D1_superclass_T = env.elementEnvironment + .getThisType(env.elementEnvironment.getSuperClass(D1)!) + .typeArguments + .first; testSupertypes(env.elementEnvironment.getSuperClass(D1)!, { A: [D1_superclass_T], B: [ @@ -248,11 +247,10 @@ testNonTrivialSubstitutions() async { instantiate(types, B, [F1_T, X]), ], }); - DartType F1_superclass_T = - env.elementEnvironment - .getThisType(env.elementEnvironment.getSuperClass(F1)!) - .typeArguments - .first; + DartType F1_superclass_T = env.elementEnvironment + .getThisType(env.elementEnvironment.getSuperClass(F1)!) + .typeArguments + .first; testSupertypes(env.elementEnvironment.getSuperClass(F1)!, { A: [X], B: [ diff --git a/pkg/compiler/test/model/native_test.dart b/pkg/compiler/test/model/native_test.dart index ef66f34154d..563b4dad009 100644 --- a/pkg/compiler/test/model/native_test.dart +++ b/pkg/compiler/test/model/native_test.dart @@ -390,10 +390,12 @@ runNegativeTest( result.isSuccess, "Expected compile time error(s) for\n$subTest", ); - List expected = - subTest.expectedErrors.map((error) => 'MessageKind.' + error).toList(); - List actual = - collector.errors.map((error) => error.messageKind.toString()).toList(); + List expected = subTest.expectedErrors + .map((error) => 'MessageKind.' + error) + .toList(); + List actual = collector.errors + .map((error) => error.messageKind.toString()) + .toList(); expected.sort(); actual.sort(); Expect.listEquals( diff --git a/pkg/compiler/test/model/no_such_method_forwarders_test.dart b/pkg/compiler/test/model/no_such_method_forwarders_test.dart index 375266c36fa..7ebf100bae7 100644 --- a/pkg/compiler/test/model/no_such_method_forwarders_test.dart +++ b/pkg/compiler/test/model/no_such_method_forwarders_test.dart @@ -152,21 +152,18 @@ main() { ); late DartType type; if (member.isFunction) { - type = - closedWorld.elementEnvironment - .getFunctionType(member as FunctionEntity) - .returnType; + type = closedWorld.elementEnvironment + .getFunctionType(member as FunctionEntity) + .returnType; } else if (member.isGetter) { - type = - closedWorld.elementEnvironment - .getFunctionType(member as FunctionEntity) - .returnType; + type = closedWorld.elementEnvironment + .getFunctionType(member as FunctionEntity) + .returnType; } else if (member.isSetter) { - type = - closedWorld.elementEnvironment - .getFunctionType(member as FunctionEntity) - .parameterTypes - .first; + type = closedWorld.elementEnvironment + .getFunctionType(member as FunctionEntity) + .parameterTypes + .first; } type = type.withoutNullability; Expect.isTrue( diff --git a/pkg/compiler/test/model/subtype_test.dart b/pkg/compiler/test/model/subtype_test.dart index 823455a7949..91f6feb3220 100644 --- a/pkg/compiler/test/model/subtype_test.dart +++ b/pkg/compiler/test/model/subtype_test.dart @@ -381,7 +381,8 @@ Future testFunctionSubtyping() async { await TypeEnvironment.create( createMethods( functionTypesData, - additionalData: """ + additionalData: + """ main() { ${createUses(functionTypesData)} } @@ -395,7 +396,8 @@ Future testTypedefSubtyping() async { await TypeEnvironment.create( createTypedefs( functionTypesData, - additionalData: """ + additionalData: + """ main() { ${createUses(functionTypesData)} } @@ -490,7 +492,8 @@ Future testFunctionSubtypingOptional() async { await TypeEnvironment.create( createMethods( optionalFunctionTypesData, - additionalData: """ + additionalData: + """ main() { ${createUses(optionalFunctionTypesData)} } @@ -504,7 +507,8 @@ Future testTypedefSubtypingOptional() async { await TypeEnvironment.create( createTypedefs( optionalFunctionTypesData, - additionalData: """ + additionalData: + """ main() { ${createUses(optionalFunctionTypesData)} } @@ -580,7 +584,8 @@ Future testFunctionSubtypingNamed() async { await TypeEnvironment.create( createMethods( namedFunctionTypesData, - additionalData: """ + additionalData: + """ main() { ${createUses(namedFunctionTypesData)} } @@ -594,7 +599,8 @@ Future testTypedefSubtypingNamed() async { await TypeEnvironment.create( createTypedefs( namedFunctionTypesData, - additionalData: """ + additionalData: + """ main() { ${createUses(namedFunctionTypesData)} } diff --git a/pkg/compiler/test/model/type_substitution_test.dart b/pkg/compiler/test/model/type_substitution_test.dart index 18d1f774d00..b9498cd10b3 100644 --- a/pkg/compiler/test/model/type_substitution_test.dart +++ b/pkg/compiler/test/model/type_substitution_test.dart @@ -13,8 +13,10 @@ import 'package:compiler/src/elements/types.dart'; import '../helpers/type_test_helper.dart'; DartType getType(ElementEnvironment elementEnvironment, String name) { - ClassEntity cls = - elementEnvironment.lookupClass(elementEnvironment.mainLibrary!, 'Class')!; + ClassEntity cls = elementEnvironment.lookupClass( + elementEnvironment.mainLibrary!, + 'Class', + )!; final element = elementEnvironment.lookupClassMember( cls, diff --git a/pkg/compiler/test/model/world_test.dart b/pkg/compiler/test/model/world_test.dart index 7666e0a466f..53f2c0ed48d 100644 --- a/pkg/compiler/test/model/world_test.dart +++ b/pkg/compiler/test/model/world_test.dart @@ -380,18 +380,28 @@ testNativeClasses() async { ElementEnvironment elementEnvironment = closedWorld.elementEnvironment; LibraryEntity dart_html = elementEnvironment.lookupLibrary(Uris.dartHtml)!; - ClassEntity clsEventTarget = - elementEnvironment.lookupClass(dart_html, 'EventTarget')!; + ClassEntity clsEventTarget = elementEnvironment.lookupClass( + dart_html, + 'EventTarget', + )!; ClassEntity clsWindow = elementEnvironment.lookupClass(dart_html, 'Window')!; - ClassEntity clsAbstractWorker = - elementEnvironment.lookupClass(dart_html, 'AbstractWorker')!; + ClassEntity clsAbstractWorker = elementEnvironment.lookupClass( + dart_html, + 'AbstractWorker', + )!; ClassEntity clsWorker = elementEnvironment.lookupClass(dart_html, 'Worker')!; - ClassEntity clsCanvasElement = - elementEnvironment.lookupClass(dart_html, 'CanvasElement')!; - ClassEntity clsCanvasRenderingContext = - elementEnvironment.lookupClass(dart_html, 'CanvasRenderingContext')!; - ClassEntity clsCanvasRenderingContext2D = - elementEnvironment.lookupClass(dart_html, 'CanvasRenderingContext2D')!; + ClassEntity clsCanvasElement = elementEnvironment.lookupClass( + dart_html, + 'CanvasElement', + )!; + ClassEntity clsCanvasRenderingContext = elementEnvironment.lookupClass( + dart_html, + 'CanvasRenderingContext', + )!; + ClassEntity clsCanvasRenderingContext2D = elementEnvironment.lookupClass( + dart_html, + 'CanvasRenderingContext2D', + )!; List allClasses = [ clsEventTarget, diff --git a/pkg/compiler/test/optimization/optimization_test.dart b/pkg/compiler/test/optimization/optimization_test.dart index 8ad86863b67..f6af5d7a928 100644 --- a/pkg/compiler/test/optimization/optimization_test.dart +++ b/pkg/compiler/test/optimization/optimization_test.dart @@ -69,8 +69,9 @@ class OptimizationDataValidator Features expectedLogEntries = Features.fromText(expectedLog); List errorsFound = []; expectedLogEntries.forEach((String tag, dynamic expectedEntryData) { - List actualDataForTag = - actualDataEntries.where((data) => data.tag == tag).toList(); + List actualDataForTag = actualDataEntries + .where((data) => data.tag == tag) + .toList(); for (OptimizationLogEntry entry in actualDataForTag) { actualDataEntries.remove(entry); } diff --git a/pkg/compiler/test/rti/rti_need_test_helper.dart b/pkg/compiler/test/rti/rti_need_test_helper.dart index d87a09e0dfe..9e6c2caee8e 100644 --- a/pkg/compiler/test/rti/rti_need_test_helper.dart +++ b/pkg/compiler/test/rti/rti_need_test_helper.dart @@ -89,20 +89,17 @@ mixin ComputeValueMixin { } void findDependencies(Features features, Entity? entity) { - Iterable dependencies = - entity == null - ? const [] - : rtiNeedBuilder.typeVariableTestsForTesting! - .getTypeArgumentDependencies(entity); + Iterable dependencies = entity == null + ? const [] + : rtiNeedBuilder.typeVariableTestsForTesting! + .getTypeArgumentDependencies(entity); if (dependencies.isNotEmpty) { - List names = - dependencies.map((Entity d) { - if (d is MemberEntity && d.enclosingClass != null) { - return '${d.enclosingClass!.name}.${d.name}'; - } - return d.name!; - }).toList() - ..sort(); + List names = dependencies.map((Entity d) { + if (d is MemberEntity && d.enclosingClass != null) { + return '${d.enclosingClass!.name}.${d.name}'; + } + return d.name!; + }).toList()..sort(); features[Tags.dependencies] = '[${names.join(',')}]'; } } @@ -325,15 +322,15 @@ mixin IrMixin implements ComputeValueMixin { MemberEntity? getFrontendMember(MemberEntity backendMember) { ElementEnvironment elementEnvironment = compiler.frontendClosedWorldForTesting!.elementEnvironment; - LibraryEntity frontendLibrary = - elementEnvironment.lookupLibrary(backendMember.library.canonicalUri)!; + LibraryEntity frontendLibrary = elementEnvironment.lookupLibrary( + backendMember.library.canonicalUri, + )!; if (backendMember.enclosingClass != null) { if (backendMember.enclosingClass!.isClosure) return null; - ClassEntity frontendClass = - elementEnvironment.lookupClass( - frontendLibrary, - backendMember.enclosingClass!.name, - )!; + ClassEntity frontendClass = elementEnvironment.lookupClass( + frontendLibrary, + backendMember.enclosingClass!.name, + )!; if (backendMember is ConstructorEntity) { return elementEnvironment.lookupConstructor( frontendClass, @@ -362,8 +359,9 @@ mixin IrMixin implements ComputeValueMixin { if (backendClass.isClosure) return null; ElementEnvironment elementEnvironment = compiler.frontendClosedWorldForTesting!.elementEnvironment; - LibraryEntity frontendLibrary = - elementEnvironment.lookupLibrary(backendClass.library.canonicalUri)!; + LibraryEntity frontendLibrary = elementEnvironment.lookupLibrary( + backendClass.library.canonicalUri, + )!; return elementEnvironment.lookupClass(frontendLibrary, backendClass.name); } diff --git a/pkg/compiler/test/rti/runtime_type_hint_test.dart b/pkg/compiler/test/rti/runtime_type_hint_test.dart index 9b0efbb19f1..2294288fda5 100644 --- a/pkg/compiler/test/rti/runtime_type_hint_test.dart +++ b/pkg/compiler/test/rti/runtime_type_hint_test.dart @@ -17,8 +17,9 @@ test(String code, List options, List expectedHints) async { diagnosticHandler: collector, ); Expect.isTrue(result.isSuccess); - List actualHints = - collector.hints.map((c) => c.messageKind).toList(); + List actualHints = collector.hints + .map((c) => c.messageKind) + .toList(); String message = "Unexpected hints for $options on\n$code\n" "Expected: ${expectedHints}\n" diff --git a/pkg/compiler/test/sourcemaps/helpers/diff.dart b/pkg/compiler/test/sourcemaps/helpers/diff.dart index 458ba8c44be..42c1ca86a0f 100644 --- a/pkg/compiler/test/sourcemaps/helpers/diff.dart +++ b/pkg/compiler/test/sourcemaps/helpers/diff.dart @@ -204,15 +204,17 @@ void align( if (element2inList1 != null) { if (element1inList2 != null) { if (element1inList2.length > 1 && element2inList1.length > 1) { - choice = - element2inList1.from < element1inList2.from ? ALIGN2 : ALIGN1; + choice = element2inList1.from < element1inList2.from + ? ALIGN2 + : ALIGN1; } else if (element2inList1.length > 1) { choice = ALIGN2; } else if (element1inList2.length > 1) { choice = ALIGN1; } else { - choice = - element2inList1.from < element1inList2.from ? ALIGN2 : ALIGN1; + choice = element2inList1.from < element1inList2.from + ? ALIGN2 + : ALIGN1; } } else { choice = ALIGN2; @@ -287,10 +289,9 @@ class DiffCreator { List parts = []; for (CodeSource codeSource in codeSources) { //parts.addAll(codeLinesFromCodeSource(codeSource)); - String className = - mainSources.contains(codeSource) - ? ClassNames.originalDart - : ClassNames.inlinedDart; + String className = mainSources.contains(codeSource) + ? ClassNames.originalDart + : ClassNames.inlinedDart; parts.add( new TagPart( 'div', @@ -732,8 +733,9 @@ class DiffCreator { CodeLineAnnotation codeLineAnnotation = annotation.data; for (CodeLocation location in codeLineAnnotation.codeLocations) { - SourceFile sourceFile = - sourceFileManager.getSourceFile(location.uri)!; + SourceFile sourceFile = sourceFileManager.getSourceFile( + location.uri, + )!; int line = sourceFile.getLocation(location.offset).line - 1; if (currentUri != location.uri) { restart(jsCodeLine, location, line); @@ -846,12 +848,12 @@ class CodeLineAnnotation { return CodeLineAnnotation( annotationId: json['id'], annotationType: AnnotationType.values[json['annotationType']], - codeLocations: - json['codeLocations'] - .map((j) => CodeLocation.fromJson(j, strategy)) - .toList(), - codeSources: - json['codeSources'].map((j) => CodeSource.fromJson(j)).toList(), + codeLocations: json['codeLocations'] + .map((j) => CodeLocation.fromJson(j, strategy)) + .toList(), + codeSources: json['codeSources'] + .map((j) => CodeSource.fromJson(j)) + .toList(), stepInfo: json['stepInfo'], sourceMappingIndex: json['sourceMappingIndex'], ); diff --git a/pkg/compiler/test/sourcemaps/helpers/html_parts.dart b/pkg/compiler/test/sourcemaps/helpers/html_parts.dart index 8715b5fe904..3639323b931 100644 --- a/pkg/compiler/test/sourcemaps/helpers/html_parts.dart +++ b/pkg/compiler/test/sourcemaps/helpers/html_parts.dart @@ -390,8 +390,9 @@ class CodePart { Map toJson(JsonStrategy strategy) { return { - 'annotations': - annotations.map((a) => strategy.encodeAnnotation(a)).toList(), + 'annotations': annotations + .map((a) => strategy.encodeAnnotation(a)) + .toList(), 'subsequentCode': subsequentCode, }; } @@ -482,12 +483,12 @@ class CodeLine extends HtmlPart { 'offset': offset, 'code': code, 'parts': codeParts.map((p) => p.toJson(strategy)).toList(), - 'annotations': - annotations.map((a) => strategy.encodeAnnotation(a)).toList(), - 'lineAnnotation': - lineAnnotation != null - ? strategy.encodeLineAnnotation(lineAnnotation) - : null, + 'annotations': annotations + .map((a) => strategy.encodeAnnotation(a)) + .toList(), + 'lineAnnotation': lineAnnotation != null + ? strategy.encodeLineAnnotation(lineAnnotation) + : null, }; } @@ -504,10 +505,9 @@ class CodeLine extends HtmlPart { json['annotations'].forEach( (a) => line.annotations.add(strategy.decodeAnnotation(a)), ); - line.lineAnnotation = - json['lineAnnotation'] != null - ? strategy.decodeLineAnnotation(json['lineAnnotation']) - : null; + line.lineAnnotation = json['lineAnnotation'] != null + ? strategy.decodeLineAnnotation(json['lineAnnotation']) + : null; return line; } } diff --git a/pkg/compiler/test/sourcemaps/helpers/output_structure.dart b/pkg/compiler/test/sourcemaps/helpers/output_structure.dart index 0bf13630273..e0eac84b570 100644 --- a/pkg/compiler/test/sourcemaps/helpers/output_structure.dart +++ b/pkg/compiler/test/sourcemaps/helpers/output_structure.dart @@ -258,14 +258,14 @@ class OutputStructure extends OutputEntity { } static OutputStructure fromJson(Map json, JsonStrategy strategy) { - List lines = - json['lines'].map((l) => CodeLine.fromJson(l, strategy)).toList(); + List lines = json['lines'] + .map((l) => CodeLine.fromJson(l, strategy)) + .toList(); int headerEnd = json['headerEnd']; int footerStart = json['footerStart']; - List children = - json['children'] - .map((j) => AbstractEntity.fromJson(j, strategy)) - .toList(); + List children = json['children'] + .map((j) => AbstractEntity.fromJson(j, strategy)) + .toList(); return OutputStructure(lines, headerEnd, footerStart, children); } } @@ -303,19 +303,17 @@ abstract class AbstractEntity extends OutputEntity { case EntityKind.STRUCTURE: throw StateError('Unexpected entity kind $kind'); case EntityKind.LIBRARY: - LibraryBlock lib = - LibraryBlock(name, from) - ..to = to - ..codeSource = codeSource; + LibraryBlock lib = LibraryBlock(name, from) + ..to = to + ..codeSource = codeSource; json['children'].forEach( (child) => lib.children.add(fromJson(child, strategy) as BasicEntity), ); return lib; case EntityKind.CLASS: - LibraryClass cls = - LibraryClass(name, from) - ..to = to - ..codeSource = codeSource; + LibraryClass cls = LibraryClass(name, from) + ..to = to + ..codeSource = codeSource; json['children'].forEach( (child) => cls.children.add(fromJson(child, strategy) as BasicEntity), ); @@ -341,10 +339,9 @@ abstract class AbstractEntity extends OutputEntity { ..to = to ..codeSource = codeSource; case EntityKind.STATICS: - Statics statics = - Statics(from) - ..to = to - ..codeSource = codeSource; + Statics statics = Statics(from) + ..to = to + ..codeSource = codeSource; json['children'].forEach( (child) => statics.children.add(fromJson(child, strategy) as BasicEntity), diff --git a/pkg/compiler/test/sourcemaps/helpers/sourcemap_helper.dart b/pkg/compiler/test/sourcemaps/helpers/sourcemap_helper.dart index 6de710d66e1..c5e257bf964 100644 --- a/pkg/compiler/test/sourcemaps/helpers/sourcemap_helper.dart +++ b/pkg/compiler/test/sourcemaps/helpers/sourcemap_helper.dart @@ -435,10 +435,9 @@ class SourceMapProcessor { bool perElement = true, bool forMain = false, }) async { - OutputProvider outputProvider = - outputToFile - ? CloningOutputProvider(targetUri, sourceMapFileUri) - : OutputProvider(); + OutputProvider outputProvider = outputToFile + ? CloningOutputProvider(targetUri, sourceMapFileUri) + : OutputProvider(); if (options.contains(Flags.useNewSourceInfo)) { if (verbose) print('Using the source information system.'); } @@ -618,8 +617,9 @@ class SourceMapInfo { this.codePoints, this.jsCodePositions, this.nodeMap, - ) : this.name = - element != null ? computeElementNameForSourceMaps(element) : ''; + ) : this.name = element != null + ? computeElementNameForSourceMaps(element) + : ''; @override String toString() { diff --git a/pkg/compiler/test/sourcemaps/helpers/sourcemap_html_helper.dart b/pkg/compiler/test/sourcemaps/helpers/sourcemap_html_helper.dart index cf157af1a84..20f29a3b4a3 100644 --- a/pkg/compiler/test/sourcemaps/helpers/sourcemap_html_helper.dart +++ b/pkg/compiler/test/sourcemaps/helpers/sourcemap_html_helper.dart @@ -101,8 +101,9 @@ class SourceLocationCollection { Map sourceLocationIndexMap; SourceLocationCollection([SourceLocationCollection? parent]) - : sourceLocationIndexMap = - parent == null ? {} : parent.sourceLocationIndexMap; + : sourceLocationIndexMap = parent == null + ? {} + : parent.sourceLocationIndexMap; int registerSourceLocation(SourceLocation sourceLocation) { return sourceLocationIndexMap.putIfAbsent(sourceLocation, () { diff --git a/pkg/compiler/test/sourcemaps/helpers/sourcemap_html_templates.dart b/pkg/compiler/test/sourcemaps/helpers/sourcemap_html_templates.dart index 03b160758fd..a5c2f77a4b3 100644 --- a/pkg/compiler/test/sourcemaps/helpers/sourcemap_html_templates.dart +++ b/pkg/compiler/test/sourcemaps/helpers/sourcemap_html_templates.dart @@ -120,7 +120,8 @@ void outputJsDartTrace( String dartCodeHtml, String jsTraceHtml, ) { - String html = ''' + String html = + '''
${jsCodeHtml}
diff --git a/pkg/compiler/test/sourcemaps/load_save_test.dart b/pkg/compiler/test/sourcemaps/load_save_test.dart index 6f265ab55b7..44db830e7c0 100644 --- a/pkg/compiler/test/sourcemaps/load_save_test.dart +++ b/pkg/compiler/test/sourcemaps/load_save_test.dart @@ -9,7 +9,8 @@ import 'tools/load.dart'; import 'tools/save.dart'; import 'package:compiler/src/util/memory_compiler.dart'; -String SOURCEMAP = ''' +String SOURCEMAP = + ''' { "version": 3, "file": "out.js", diff --git a/pkg/compiler/test/sourcemaps/stacktrace_test.dart b/pkg/compiler/test/sourcemaps/stacktrace_test.dart index aac20dccc1a..907d518d1ef 100644 --- a/pkg/compiler/test/sourcemaps/stacktrace_test.dart +++ b/pkg/compiler/test/sourcemaps/stacktrace_test.dart @@ -105,10 +105,9 @@ Future runTest( CompilationResult compilationResult = await entry.internalMain(arguments); return compilationResult.isSuccess; }, - jsPreambles: - (input, output) => [ - '$sdkPath/_internal/js_runtime/lib/preambles/d8.js', - ], + jsPreambles: (input, output) => [ + '$sdkPath/_internal/js_runtime/lib/preambles/d8.js', + ], afterExceptions: testAfterExceptions, beforeExceptions: beforeExceptions, verbose: verbose, diff --git a/pkg/compiler/test/sourcemaps/tools/diff_view.dart b/pkg/compiler/test/sourcemaps/tools/diff_view.dart index 6dbf432c8e5..5fb56c5ad0e 100644 --- a/pkg/compiler/test/sourcemaps/tools/diff_view.dart +++ b/pkg/compiler/test/sourcemaps/tools/diff_view.dart @@ -506,12 +506,11 @@ as mapped through source-maps."> allColumns.addAll(block.columns); } - List columns = - [ - column_js0, - column_js1, - column_dart, - ].where((c) => allColumns.contains(c)).toList(); + List columns = [ + column_js0, + column_js1, + column_dart, + ].where((c) => allColumns.contains(c)).toList(); sb.write(''' @@ -703,8 +702,8 @@ class CodeSources { } uriCodeSourceMap.forEach((Uri uri, Map intervals) { - List sortedKeys = - intervals.keys.toList()..sort((i1, i2) => i1.from.compareTo(i2.from)); + List sortedKeys = intervals.keys.toList() + ..sort((i1, i2) => i1.from.compareTo(i2.from)); Map sortedintervals = {}; sortedKeys.forEach((Interval interval) { sortedintervals[interval] = intervals[interval]!; @@ -766,17 +765,15 @@ Future computeCodeLines( annotationType == AnnotationType.unusedSourceInfo) { locations = []; } - List codeLocations = - locations - .where((l) => l.sourceUri != null) - .map((l) => CodeLocation(l.sourceUri!, l.sourceName!, l.offset)) - .toList(); - List codeSourceList = - locations - .where((l) => l.sourceUri != null) - .map(codeSources.sourceLocationToCodeSource) - .whereType() - .toList(); + List codeLocations = locations + .where((l) => l.sourceUri != null) + .map((l) => CodeLocation(l.sourceUri!, l.sourceName!, l.offset)) + .toList(); + List codeSourceList = locations + .where((l) => l.sourceUri != null) + .map(codeSources.sourceLocationToCodeSource) + .whereType() + .toList(); CodeLineAnnotation data = CodeLineAnnotation( annotationId: nextAnnotationId++, annotationType: annotationType, diff --git a/pkg/compiler/test/sourcemaps/tools/source_mapping_test_viewer.dart b/pkg/compiler/test/sourcemaps/tools/source_mapping_test_viewer.dart index 895d3495b99..4ec75d0dc53 100644 --- a/pkg/compiler/test/sourcemaps/tools/source_mapping_test_viewer.dart +++ b/pkg/compiler/test/sourcemaps/tools/source_mapping_test_viewer.dart @@ -147,10 +147,9 @@ Future runTest( } List infoList = result.userInfoList; if (missingOnly) { - infoList = - infoList - .where((info) => result.missingCodePointsMap.containsKey(info)) - .toList(); + infoList = infoList + .where((info) => result.missingCodePointsMap.containsKey(info)) + .toList(); } createTraceSourceMapHtml(outputUri, result.processor, infoList); } diff --git a/pkg/compiler/test/sourcemaps/tools/sourcemap_visualizer.dart b/pkg/compiler/test/sourcemaps/tools/sourcemap_visualizer.dart index 1fb83b0afbe..c7407e4b445 100644 --- a/pkg/compiler/test/sourcemaps/tools/sourcemap_visualizer.dart +++ b/pkg/compiler/test/sourcemaps/tools/sourcemap_visualizer.dart @@ -162,8 +162,9 @@ void generateHtml(String jsFileName, String jsMapFileName) { write(line.substring(columnNo, entry.column), lastEntry); columnNo = entry.column; } - state = - entry.sourceUrlId != null ? state.nextState : MappingState.unmapped; + state = entry.sourceUrlId != null + ? state.nextState + : MappingState.unmapped; int end; if (index + 1 < targetLineEntry.entries.length) { end = targetLineEntry.entries[index + 1].column; diff --git a/pkg/compiler/test/sourcemaps/tools/translate_dart2js_stacktrace.dart b/pkg/compiler/test/sourcemaps/tools/translate_dart2js_stacktrace.dart index 4884cf8afe3..62813ef7a8f 100644 --- a/pkg/compiler/test/sourcemaps/tools/translate_dart2js_stacktrace.dart +++ b/pkg/compiler/test/sourcemaps/tools/translate_dart2js_stacktrace.dart @@ -7,14 +7,14 @@ import 'package:args/args.dart'; import 'package:http/http.dart' as http; import 'package:source_maps/source_maps.dart'; -ArgParser parser = - ArgParser()..addFlag( - 'inline', - abbr: 'i', - negatable: true, - help: 'Inline untranslatable parts..', - defaultsTo: false, - ); +ArgParser parser = ArgParser() + ..addFlag( + 'inline', + abbr: 'i', + negatable: true, + help: 'Inline untranslatable parts..', + defaultsTo: false, + ); main(List arguments) async { ArgResults options = parser.parse(arguments); diff --git a/pkg/compiler/tool/hot_reload_launcher.dart b/pkg/compiler/tool/hot_reload_launcher.dart index 0e3a4ac6ba6..4824aa0e6d7 100644 --- a/pkg/compiler/tool/hot_reload_launcher.dart +++ b/pkg/compiler/tool/hot_reload_launcher.dart @@ -67,8 +67,9 @@ Future main(List args) async { final wsUri = 'ws://${observatoryUri.authority}${observatoryUri.path}ws'; final vmService = await vm_service_io.vmServiceConnectUri(wsUri); final vm = await vmService.getVM(); - final id = - vm.isolates!.firstWhere((isolate) => !isolate.isSystemIsolate!).id!; + final id = vm.isolates! + .firstWhere((isolate) => !isolate.isSystemIsolate!) + .id!; // Override exitFunc to prevent the defualt behavior (a process exit). p.exitFunc = (code) { diff --git a/pkg/compiler/tool/kernel_visitor/dart_html_metrics_visitor.dart b/pkg/compiler/tool/kernel_visitor/dart_html_metrics_visitor.dart index 9d6e5e7ac4b..5cb0c03ab9a 100644 --- a/pkg/compiler/tool/kernel_visitor/dart_html_metrics_visitor.dart +++ b/pkg/compiler/tool/kernel_visitor/dart_html_metrics_visitor.dart @@ -42,12 +42,11 @@ class MetricsVisitor extends RecursiveVisitor { @override void visitLibrary(Library node) { // Check if this is a library we want to visit. - var visit = - libraryFilter.isNotEmpty - ? libraryFilter.contains( - "${node.importUri.scheme}:${node.importUri.path}", - ) - : true; + var visit = libraryFilter.isNotEmpty + ? libraryFilter.contains( + "${node.importUri.scheme}:${node.importUri.path}", + ) + : true; if (visit) { super.visitLibrary(node); diff --git a/pkg/compiler/tool/kernel_visitor/test/info_visitor_test.dart b/pkg/compiler/tool/kernel_visitor/test/info_visitor_test.dart index c867c037d51..b021ae54235 100644 --- a/pkg/compiler/tool/kernel_visitor/test/info_visitor_test.dart +++ b/pkg/compiler/tool/kernel_visitor/test/info_visitor_test.dart @@ -20,10 +20,9 @@ void runTests(MetricsVisitor visitor) { test("Class B does call super", () { Expect.equals(visitor.classInfo["B"]!.invokesSuper, true); - var callingMethod = - visitor.classInfo["B"]!.methods - .where((m) => m.name == "testSuper") - .toList()[0]; + var callingMethod = visitor.classInfo["B"]!.methods + .where((m) => m.name == "testSuper") + .toList()[0]; Expect.equals(callingMethod.invokesSuper, true); }); diff --git a/pkg/compiler/tool/modular_test_suite_helper.dart b/pkg/compiler/tool/modular_test_suite_helper.dart index 9babb9ddf3b..7a6324099bb 100644 --- a/pkg/compiler/tool/modular_test_suite_helper.dart +++ b/pkg/compiler/tool/modular_test_suite_helper.dart @@ -59,10 +59,9 @@ String getRootScheme(Module module) { String sourceToImportUri(Module module, Uri relativeUri) { if (module.isPackage) { var basePath = module.packageBase!.path; - var packageRelativePath = - basePath == "./" - ? relativeUri.path - : relativeUri.path.substring(basePath.length); + var packageRelativePath = basePath == "./" + ? relativeUri.path + : relativeUri.path.substring(basePath.length); return 'package:${module.name}/$packageRelativePath'; } else { return '${getRootScheme(module)}:/$relativeUri'; @@ -707,13 +706,13 @@ Future resolveScripts(Options options) async { String relativeSnapshotPath, ) async { Uri sourceUri = sdkRoot.resolve(sourceUriOrPath); - String result = - sourceUri.isScheme('file') ? sourceUri.toFilePath() : sourceUriOrPath; + String result = sourceUri.isScheme('file') + ? sourceUri.toFilePath() + : sourceUriOrPath; if (_options.useSdk) { - String snapshot = - Uri.file( - Platform.resolvedExecutable, - ).resolve(relativeSnapshotPath).toFilePath(); + String snapshot = Uri.file( + Platform.resolvedExecutable, + ).resolve(relativeSnapshotPath).toFilePath(); if (await File(snapshot).exists()) { return snapshot; } @@ -732,7 +731,6 @@ Future resolveScripts(Options options) async { ); } -String _librarySpecForSnapshot = - Uri.file( - Platform.resolvedExecutable, - ).resolve('../lib/libraries.json').toFilePath(); +String _librarySpecForSnapshot = Uri.file( + Platform.resolvedExecutable, +).resolve('../lib/libraries.json').toFilePath();