From c5cd8ff349968f196a5df421cd3bfaf091753b1f Mon Sep 17 00:00:00 2001 From: Johnni Winther Date: Thu, 6 Jun 2024 11:02:37 +0000 Subject: [PATCH] [cfe] Remove agnostic mode The agnostic mode was added to allow the platform dill embedded in the VM to support both weak and strong mode. Since weak mode is no longer supported in the VM, the agnostic mode can new be deleted. All uses of the agnostic in Dart and Flutter have been removed prior to this change. Change-Id: Iff0f69d9cd64e887e01cd7e7d336a97761bd6d4b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366801 Reviewed-by: Alexander Thomas Commit-Queue: Johnni Winther Reviewed-by: Jens Johansen --- build/rbe/rewrapper_dart.py | 1 - .../lib/src/messages/codes_generated.dart | 31 -- .../src/api_prototype/compiler_options.dart | 3 +- .../lib/src/base/command_line_options.dart | 3 - pkg/front_end/lib/src/base/nnbd_mode.dart | 1 - .../lib/src/base/processed_options.dart | 4 +- .../compute_platform_binaries_location.dart | 11 - .../lib/src/fasta/incremental_compiler.dart | 11 - .../kernel/constant_collection_builders.dart | 18 +- .../src/fasta/kernel/constant_evaluator.dart | 265 +----------------- .../lib/src/fasta/kernel/kernel_target.dart | 24 +- .../fasta/source/source_library_builder.dart | 4 - .../lib/src/fasta/source/source_loader.dart | 17 +- .../lib/src/kernel_generator_impl.dart | 3 - pkg/front_end/messages.yaml | 9 - .../test/compile_platform_coverage.dart | 2 +- .../test/fasta/testing/folder_options.dart | 7 - pkg/front_end/test/fasta/testing/suite.dart | 2 +- .../test/fasta/testing/test_options.dart | 8 - pkg/front_end/test/incremental_suite.dart | 15 - pkg/front_end/tool/_fasta/command_line.dart | 19 +- pkg/kernel/lib/ast.dart | 7 +- pkg/kernel/lib/binary/ast_from_binary.dart | 9 - .../test/binary/component_mode_test.dart | 8 +- .../test/binary/library_flags_test.dart | 1 - tools/bots/flutter/compile_flutter.sh | 4 +- 26 files changed, 18 insertions(+), 469 deletions(-) diff --git a/build/rbe/rewrapper_dart.py b/build/rbe/rewrapper_dart.py index fec2d03505c..17efc0baacc 100644 --- a/build/rbe/rewrapper_dart.py +++ b/build/rbe/rewrapper_dart.py @@ -475,7 +475,6 @@ trace to find the place to insert the appropriate support. '--no-defines', '--nnbd-strong', '--nnbd-weak', - '--nnbd-agnostic', '--exclude-source', ]: pass diff --git a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart index 5654df8a14f..40f403d615e 100644 --- a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart +++ b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart @@ -241,28 +241,6 @@ Message _withArgumentsAccessError(String name) { ); } -// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. -const Code codeAgnosticWithStrongDillLibrary = - messageAgnosticWithStrongDillLibrary; - -// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. -const MessageCode messageAgnosticWithStrongDillLibrary = const MessageCode( - "AgnosticWithStrongDillLibrary", - problemMessage: - r"""Loaded library is compiled with sound null safety and cannot be used in compilation for agnostic null safety.""", -); - -// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. -const Code codeAgnosticWithWeakDillLibrary = - messageAgnosticWithWeakDillLibrary; - -// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. -const MessageCode messageAgnosticWithWeakDillLibrary = const MessageCode( - "AgnosticWithWeakDillLibrary", - problemMessage: - r"""Loaded library is compiled with unsound null safety and cannot be used in compilation for agnostic null safety.""", -); - // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. const Code codeAmbiguousExtensionCause = messageAmbiguousExtensionCause; @@ -12913,15 +12891,6 @@ const MessageCode messageNoUnnamedConstructorInObject = const MessageCode( problemMessage: r"""'Object' has no unnamed constructor.""", ); -// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. -const Code codeNonAgnosticConstant = messageNonAgnosticConstant; - -// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. -const MessageCode messageNonAgnosticConstant = const MessageCode( - "NonAgnosticConstant", - problemMessage: r"""Constant value is not strong/weak mode agnostic.""", -); - // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. const Template templateNonAsciiIdentifier = diff --git a/pkg/front_end/lib/src/api_prototype/compiler_options.dart b/pkg/front_end/lib/src/api_prototype/compiler_options.dart index b5b224ad384..27a7656bc8f 100644 --- a/pkg/front_end/lib/src/api_prototype/compiler_options.dart +++ b/pkg/front_end/lib/src/api_prototype/compiler_options.dart @@ -256,8 +256,7 @@ class CompilerOptions { /// Whether to write a file (e.g. a dill file) when reporting a crash. bool writeFileOnCrashReport = true; - /// Whether nnbd weak, strong or agnostic mode is used if experiment - /// 'non-nullable' is enabled. + /// Whether nnbd weak or strong mode is used. NnbdMode nnbdMode = NnbdMode.Strong; /// The current sdk version string, e.g. "2.6.0-edge.sha1hash". diff --git a/pkg/front_end/lib/src/base/command_line_options.dart b/pkg/front_end/lib/src/base/command_line_options.dart index 567ae01194f..92c402e1431 100644 --- a/pkg/front_end/lib/src/base/command_line_options.dart +++ b/pkg/front_end/lib/src/base/command_line_options.dart @@ -9,7 +9,6 @@ import 'package:kernel/target/targets.dart'; class Flags { // TODO(johnniwinther): What is the right name for this? static const String nnbdStrongMode = "--nnbd-strong"; - static const String nnbdAgnosticMode = "--nnbd-agnostic"; static const String nnbdWeakMode = "--nnbd-weak"; static const String forceLateLowering = "--force-late-lowering"; @@ -115,8 +114,6 @@ class Options { const Option(Flags.nnbdWeakMode, const BoolValue(false)); static const Option nnbdStrongMode = const Option(Flags.nnbdStrongMode, const BoolValue(false)); - static const Option nnbdAgnosticMode = - const Option(Flags.nnbdAgnosticMode, const BoolValue(false)); static const Option target = const Option( Flags.target, const StringValue(defaultValue: 'vm'), aliases: ["-t"]); diff --git a/pkg/front_end/lib/src/base/nnbd_mode.dart b/pkg/front_end/lib/src/base/nnbd_mode.dart index ef19ae06124..416d0f56879 100644 --- a/pkg/front_end/lib/src/base/nnbd_mode.dart +++ b/pkg/front_end/lib/src/base/nnbd_mode.dart @@ -5,5 +5,4 @@ enum NnbdMode { Strong, Weak, - Agnostic, } diff --git a/pkg/front_end/lib/src/base/processed_options.dart b/pkg/front_end/lib/src/base/processed_options.dart index a6f57c579f8..d38a0eeae30 100644 --- a/pkg/front_end/lib/src/base/processed_options.dart +++ b/pkg/front_end/lib/src/base/processed_options.dart @@ -298,7 +298,6 @@ class ProcessedOptions { messageCompilingWithoutSoundNullSafety.severity); break; case NnbdMode.Strong: - case NnbdMode.Agnostic: break; } } @@ -430,8 +429,7 @@ class ProcessedOptions { '${component.libraries.join('\n')}'); } if (nnbdMode == NnbdMode.Strong && - !(component.mode == NonNullableByDefaultCompiledMode.Strong || - component.mode == NonNullableByDefaultCompiledMode.Agnostic)) { + component.mode != NonNullableByDefaultCompiledMode.Strong) { throw new FormatException( 'Provided .dill file for the following libraries does not ' 'support sound null safety:\n' diff --git a/pkg/front_end/lib/src/compute_platform_binaries_location.dart b/pkg/front_end/lib/src/compute_platform_binaries_location.dart index c8528f83066..b8c726cc4a7 100644 --- a/pkg/front_end/lib/src/compute_platform_binaries_location.dart +++ b/pkg/front_end/lib/src/compute_platform_binaries_location.dart @@ -34,30 +34,21 @@ String? computePlatformDillName( return 'ddc_outline_unsound.dill'; //TODO(johnniwinther): Support using the full dill. //return 'ddc_platform_unsound.dill'; - case NnbdMode.Agnostic: - break; } - break; case 'dart2js': switch (nnbdMode) { case NnbdMode.Strong: return 'dart2js_platform.dill'; case NnbdMode.Weak: return 'dart2js_platform_unsound.dill'; - case NnbdMode.Agnostic: - break; } - break; case 'dart2js_server': switch (nnbdMode) { case NnbdMode.Strong: return 'dart2js_server_platform.dill'; case NnbdMode.Weak: return 'dart2js_server_platform_unsound.dill'; - case NnbdMode.Agnostic: - break; } - break; case 'vm': // TODO(johnniwinther): Stop generating 'vm_platform.dill' and rename // 'vm_platform_strong.dill' to 'vm_platform.dill'. @@ -71,7 +62,6 @@ String? computePlatformDillName( //TODO(johnniwinther): Support using the full dill. //return 'dart2wasm_platform.dill'; case NnbdMode.Weak: - case NnbdMode.Agnostic: break; } break; @@ -82,7 +72,6 @@ String? computePlatformDillName( //TODO(johnniwinther): Support using the full dill. //return 'dart2wasm_js_compatibility_platform.dill'; case NnbdMode.Weak: - case NnbdMode.Agnostic: break; } break; diff --git a/pkg/front_end/lib/src/fasta/incremental_compiler.dart b/pkg/front_end/lib/src/fasta/incremental_compiler.dart index 386fb61e69c..2c94bd37d20 100644 --- a/pkg/front_end/lib/src/fasta/incremental_compiler.dart +++ b/pkg/front_end/lib/src/fasta/incremental_compiler.dart @@ -1009,14 +1009,6 @@ class IncrementalCompiler implements IncrementalKernelGenerator { kernelTarget.loader.hasInvalidNnbdModeLibrary = true; } break; - case NnbdMode.Agnostic: - // Don't expect strong, weak or invalid. - if (seenModes[NonNullableByDefaultCompiledMode.Strong.index] || - seenModes[NonNullableByDefaultCompiledMode.Weak.index] || - seenModes[NonNullableByDefaultCompiledMode.Invalid.index]) { - kernelTarget.loader.hasInvalidNnbdModeLibrary = true; - } - break; } } else { // Don't expect strong or invalid. @@ -2705,9 +2697,6 @@ class _InitializationFromUri extends _InitializationFromSdkSummary { case NnbdMode.Strong: compiledMode = NonNullableByDefaultCompiledMode.Strong; break; - case NnbdMode.Agnostic: - compiledMode = NonNullableByDefaultCompiledMode.Agnostic; - break; } } else { compiledMode = NonNullableByDefaultCompiledMode.Weak; diff --git a/pkg/front_end/lib/src/fasta/kernel/constant_collection_builders.dart b/pkg/front_end/lib/src/fasta/kernel/constant_collection_builders.dart index 1a14935d801..1efe54210ac 100644 --- a/pkg/front_end/lib/src/fasta/kernel/constant_collection_builders.dart +++ b/pkg/front_end/lib/src/fasta/kernel/constant_collection_builders.dart @@ -172,15 +172,6 @@ class SetConstantBuilder extends _ListOrSetConstantBuilder { return evaluator.createEvaluationErrorConstant( context, templateConstEvalDuplicateElement.withArguments(constant)); } - if (evaluator.evaluationMode == EvaluationMode.agnostic) { - Constant weakConstant = - evaluator._weakener.visitConstant(constant) ?? constant; - bool weakUnseen = weakSeen.add(weakConstant); - if (unseen != weakUnseen) { - return evaluator.createEvaluationErrorConstant( - context, messageNonAgnosticConstant); - } - } List lastPart; if (parts.last is List) { @@ -318,14 +309,7 @@ class MapConstantBuilder { return evaluator.createEvaluationErrorConstant( keyContext, templateConstEvalDuplicateKey.withArguments(key)); } - if (evaluator.evaluationMode == EvaluationMode.agnostic) { - Constant weakKey = evaluator._weakener.visitConstant(key) ?? key; - bool weakUnseenKey = weakSeenKeys.add(weakKey); - if (unseenKey != weakUnseenKey) { - return evaluator.createEvaluationErrorConstant( - keyContext, messageNonAgnosticConstant); - } - } + Constant key2 = evaluator.ensureIsSubtype(key, keyType, keyContext); if (key2 is AbortConstant) return key2; Constant value2 = evaluator.ensureIsSubtype(value, valueType, valueContext); diff --git a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart index 7338d27876c..6967d7fd23a 100644 --- a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart +++ b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart @@ -116,7 +116,6 @@ void transformProcedure( enum EvaluationMode { weak, - agnostic, strong; static EvaluationMode fromNnbdMode(NnbdMode nnbdMode) { @@ -125,226 +124,10 @@ enum EvaluationMode { return EvaluationMode.weak; case NnbdMode.Strong: return EvaluationMode.strong; - case NnbdMode.Agnostic: - return EvaluationMode.agnostic; } } } -class ConstantWeakener extends ComputeOnceConstantVisitor { - ConstantEvaluator _evaluator; - - ConstantWeakener(this._evaluator); - - @override - Constant? processValue(Constant node, Constant? value) { - if (value != null) { - value = _evaluator.canonicalize(value); - } - return value; - } - - @override - Constant? visitNullConstant(NullConstant node) => null; - - @override - Constant? visitBoolConstant(BoolConstant node) => null; - - @override - Constant? visitIntConstant(IntConstant node) => null; - - @override - Constant? visitDoubleConstant(DoubleConstant node) => null; - - @override - Constant? visitStringConstant(StringConstant node) => null; - - @override - Constant? visitSymbolConstant(SymbolConstant node) => null; - - @override - Constant? visitMapConstant(MapConstant node) { - DartType? keyType = - computeConstCanonicalType(node.keyType, _evaluator.coreTypes); - DartType? valueType = - computeConstCanonicalType(node.valueType, _evaluator.coreTypes); - List? entries; - for (int index = 0; index < node.entries.length; index++) { - ConstantMapEntry entry = node.entries[index]; - Constant? key = visitConstant(entry.key); - Constant? value = visitConstant(entry.value); - if (key != null || value != null) { - entries ??= node.entries.toList(growable: false); - entries[index] = - new ConstantMapEntry(key ?? entry.key, value ?? entry.value); - } - } - if (keyType != null || valueType != null || entries != null) { - return new MapConstant(keyType ?? node.keyType, - valueType ?? node.valueType, entries ?? node.entries); - } - return null; - } - - @override - Constant? visitListConstant(ListConstant node) { - DartType? typeArgument = - computeConstCanonicalType(node.typeArgument, _evaluator.coreTypes); - List? entries; - for (int index = 0; index < node.entries.length; index++) { - Constant? entry = visitConstant(node.entries[index]); - if (entry != null) { - entries ??= node.entries.toList(growable: false); - entries[index] = entry; - } - } - if (typeArgument != null || entries != null) { - return new ListConstant( - typeArgument ?? node.typeArgument, entries ?? node.entries); - } - return null; - } - - @override - Constant? visitSetConstant(SetConstant node) { - DartType? typeArgument = - computeConstCanonicalType(node.typeArgument, _evaluator.coreTypes); - List? entries; - for (int index = 0; index < node.entries.length; index++) { - Constant? entry = visitConstant(node.entries[index]); - if (entry != null) { - entries ??= node.entries.toList(growable: false); - entries[index] = entry; - } - } - if (typeArgument != null || entries != null) { - return new SetConstant( - typeArgument ?? node.typeArgument, entries ?? node.entries); - } - return null; - } - - @override - Constant? visitRecordConstant(RecordConstant node) { - RecordType? recordType = - computeConstCanonicalType(node.recordType, _evaluator.coreTypes) - as RecordType?; - List? positional; - for (int index = 0; index < node.positional.length; index++) { - Constant? field = visitConstant(node.positional[index]); - if (field != null) { - positional ??= node.positional.toList(growable: false); - positional[index] = field; - } - } - Map? named; - for (MapEntry entry in node.named.entries) { - Constant? value = visitConstant(entry.value); - if (value != null) { - named ??= new Map.of(node.named); - named[entry.key] = value; - } - } - if (recordType != null || positional != null || named != null) { - return new RecordConstant(positional ?? node.positional, - named ?? node.named, recordType ?? node.recordType); - } - return null; - } - - @override - Constant? visitInstanceConstant(InstanceConstant node) { - List? typeArguments; - for (int index = 0; index < node.typeArguments.length; index++) { - DartType? typeArgument = computeConstCanonicalType( - node.typeArguments[index], _evaluator.coreTypes); - if (typeArgument != null) { - typeArguments ??= node.typeArguments.toList(growable: false); - typeArguments[index] = typeArgument; - } - } - Map? fieldValues; - for (MapEntry entry in node.fieldValues.entries) { - Reference reference = entry.key; - Constant? value = visitConstant(entry.value); - if (value != null) { - fieldValues ??= new Map.of(node.fieldValues); - fieldValues[reference] = value; - } - } - if (typeArguments != null || fieldValues != null) { - return new InstanceConstant(node.classReference, - typeArguments ?? node.typeArguments, fieldValues ?? node.fieldValues); - } - return null; - } - - @override - Constant? visitInstantiationConstant(InstantiationConstant node) { - List? types; - for (int index = 0; index < node.types.length; index++) { - DartType? type = - computeConstCanonicalType(node.types[index], _evaluator.coreTypes); - if (type != null) { - types ??= node.types.toList(growable: false); - types[index] = type; - } - } - if (types != null) { - return new InstantiationConstant(node.tearOffConstant, types); - } - return null; - } - - @override - Constant? visitStaticTearOffConstant(StaticTearOffConstant node) => null; - - @override - Constant? visitTypeLiteralConstant(TypeLiteralConstant node) { - DartType? type = computeConstCanonicalType(node.type, _evaluator.coreTypes); - if (type != null) { - return new TypeLiteralConstant(type); - } - return null; - } - - @override - Constant? visitUnevaluatedConstant(UnevaluatedConstant node) => null; - - @override - Constant? visitConstructorTearOffConstant(ConstructorTearOffConstant node) => - null; - - @override - Constant? visitRedirectingFactoryTearOffConstant( - RedirectingFactoryTearOffConstant node) => - null; - - @override - Constant? visitTypedefTearOffConstant(TypedefTearOffConstant node) { - List? types; - for (int index = 0; index < node.types.length; index++) { - DartType? type = - computeConstCanonicalType(node.types[index], _evaluator.coreTypes); - if (type != null) { - types ??= node.types.toList(growable: false); - types[index] = type; - } - } - if (types != null) { - return new TypedefTearOffConstant( - node.parameters, node.tearOffConstant, types); - } - return null; - } - - @override - Constant? visitAuxiliaryConstant(AuxiliaryConstant node) { - throw new UnsupportedError( - 'Unsupported auxiliary constant $node (${node.runtimeType}).'); - } -} - class ConstantsTransformer extends RemovingTransformer { final ConstantsBackend backend; final ConstantEvaluator constantEvaluator; @@ -2447,8 +2230,6 @@ class ConstantEvaluator implements ExpressionVisitor { Library get currentLibrary => staticTypeContext.enclosingLibrary; - late ConstantWeakener _weakener; - ConstantEvaluator(this.dartLibrarySupport, this.backend, this.component, this._environmentDefines, this.typeEnvironment, this.errorReporter, {this.enableTripleShift = false, @@ -2487,7 +2268,6 @@ class ConstantEvaluator implements ExpressionVisitor { coreTypes.typeClass: true, }; primitiveHashCodeCache = {...primitiveEqualCache}; - _weakener = new ConstantWeakener(this); } Map? _supportedLibrariesCache; @@ -2524,7 +2304,6 @@ class ConstantEvaluator implements ExpressionVisitor { DartType convertType(DartType type) { switch (evaluationMode) { case EvaluationMode.strong: - case EvaluationMode.agnostic: return norm(coreTypes, type); case EvaluationMode.weak: type = norm(coreTypes, type); @@ -2535,7 +2314,6 @@ class ConstantEvaluator implements ExpressionVisitor { List convertTypes(List types) { switch (evaluationMode) { case EvaluationMode.strong: - case EvaluationMode.agnostic: return types.map((DartType type) => norm(coreTypes, type)).toList(); case EvaluationMode.weak: return types.map((DartType type) { @@ -4370,13 +4148,6 @@ class ConstantEvaluator implements ExpressionVisitor { StaticTypeContext? oldStaticTypeContext = _staticTypeContext; _staticTypeContext = new StaticTypeContext(member, typeEnvironment); Constant constant = _evaluateSubexpression(expression); - if (constant is! AbortConstant) { - if (staticTypeContext.nonNullableByDefaultCompiledMode == - NonNullableByDefaultCompiledMode.Agnostic && - evaluationMode == EvaluationMode.weak) { - constant = _weakener.visitConstant(constant) ?? constant; - } - } _staticTypeContext = oldStaticTypeContext; return constant; } @@ -4628,20 +4399,7 @@ class ConstantEvaluator implements ExpressionVisitor { Constant evaluateIdentical() { // Since we canonicalize constants during the evaluation, we can use // identical here. - Constant result = makeBoolConstant(identical(left, right)); - if (evaluationMode == EvaluationMode.agnostic) { - Constant? weakLeft = _weakener.visitConstant(left); - Constant? weakRight = _weakener.visitConstant(right); - if (weakLeft != null || weakRight != null) { - Constant weakResult = makeBoolConstant( - identical(weakLeft ?? left, weakRight ?? right)); - if (!identical(result, weakResult)) { - return createEvaluationErrorConstant( - node, messageNonAgnosticConstant); - } - } - } - return result; + return makeBoolConstant(identical(left, right)); } if (targetingJavaScript) { @@ -4793,15 +4551,6 @@ class ConstantEvaluator implements ExpressionVisitor { switch (evaluationMode) { case EvaluationMode.strong: return makeBoolConstant(performIs(constant, strongMode: true)); - case EvaluationMode.agnostic: - bool strongResult = performIs(constant, strongMode: true); - Constant weakConstant = _weakener.visitConstant(constant) ?? constant; - bool weakResult = performIs(weakConstant, strongMode: false); - if (strongResult != weakResult) { - return createEvaluationErrorConstant( - node, messageNonAgnosticConstant); - } - return makeBoolConstant(strongResult); case EvaluationMode.weak: return makeBoolConstant(performIs(constant, strongMode: false)); } @@ -5105,18 +4854,6 @@ class ConstantEvaluator implements ExpressionVisitor { case EvaluationMode.strong: result = isSubtype(constant, type, SubtypeCheckMode.withNullabilities); break; - case EvaluationMode.agnostic: - bool strongResult = - isSubtype(constant, type, SubtypeCheckMode.withNullabilities); - Constant weakConstant = _weakener.visitConstant(constant) ?? constant; - bool weakResult = isSubtype( - weakConstant, type, SubtypeCheckMode.ignoringNullabilities); - if (strongResult != weakResult) { - return createEvaluationErrorConstant( - node, messageNonAgnosticConstant); - } - result = strongResult; - break; case EvaluationMode.weak: result = isSubtype(constant, type, SubtypeCheckMode.ignoringNullabilities); diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart index a3a7529b649..0af5fac99a0 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart @@ -735,9 +735,6 @@ class KernelTarget { case NnbdMode.Strong: compiledMode = NonNullableByDefaultCompiledMode.Strong; break; - case NnbdMode.Agnostic: - compiledMode = NonNullableByDefaultCompiledMode.Agnostic; - break; } } else { compiledMode = NonNullableByDefaultCompiledMode.Weak; @@ -815,25 +812,14 @@ class KernelTarget { for (Library library in component.libraries) { if (component.mode == NonNullableByDefaultCompiledMode.Strong) { if (library.nonNullableByDefaultCompiledMode != - NonNullableByDefaultCompiledMode.Strong && - library.nonNullableByDefaultCompiledMode != - NonNullableByDefaultCompiledMode.Agnostic) { - return "Expected library ${library.importUri} to be strong or " - "agnostic, but was ${library.nonNullableByDefaultCompiledMode}"; + NonNullableByDefaultCompiledMode.Strong) { + return "Expected library ${library.importUri} to be strong, " + "but was ${library.nonNullableByDefaultCompiledMode}"; } } else if (component.mode == NonNullableByDefaultCompiledMode.Weak) { if (library.nonNullableByDefaultCompiledMode != - NonNullableByDefaultCompiledMode.Weak && - library.nonNullableByDefaultCompiledMode != - NonNullableByDefaultCompiledMode.Agnostic) { - return "Expected library ${library.importUri} to be weak or " - "agnostic, but was ${library.nonNullableByDefaultCompiledMode}"; - } - } else if (component.mode == - NonNullableByDefaultCompiledMode.Agnostic) { - if (library.nonNullableByDefaultCompiledMode != - NonNullableByDefaultCompiledMode.Agnostic) { - return "Expected library ${library.importUri} to be agnostic, " + NonNullableByDefaultCompiledMode.Weak) { + return "Expected library ${library.importUri} to be weak, " "but was ${library.nonNullableByDefaultCompiledMode}"; } } else { diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart index 49e8cb17110..6e69f937cc5 100644 --- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart +++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart @@ -450,10 +450,6 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { library.nonNullableByDefaultCompiledMode = NonNullableByDefaultCompiledMode.Strong; break; - case NnbdMode.Agnostic: - library.nonNullableByDefaultCompiledMode = - NonNullableByDefaultCompiledMode.Agnostic; - break; } } diff --git a/pkg/front_end/lib/src/fasta/source/source_loader.dart b/pkg/front_end/lib/src/fasta/source/source_loader.dart index 5afec21c008..97dec8b7186 100644 --- a/pkg/front_end/lib/src/fasta/source/source_loader.dart +++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart @@ -506,30 +506,17 @@ class SourceLoader extends Loader { } else { switch (nnbdMode) { case NnbdMode.Weak: - if (libraryMode != NonNullableByDefaultCompiledMode.Agnostic && - libraryMode != NonNullableByDefaultCompiledMode.Weak) { + if (libraryMode != NonNullableByDefaultCompiledMode.Weak) { registerNnbdMismatchLibrary( libraryBuilder, messageWeakWithStrongDillLibrary); } break; case NnbdMode.Strong: - if (libraryMode != NonNullableByDefaultCompiledMode.Agnostic && - libraryMode != NonNullableByDefaultCompiledMode.Strong) { + if (libraryMode != NonNullableByDefaultCompiledMode.Strong) { registerNnbdMismatchLibrary( libraryBuilder, messageStrongWithWeakDillLibrary); } break; - case NnbdMode.Agnostic: - if (libraryMode != NonNullableByDefaultCompiledMode.Agnostic) { - if (libraryMode == NonNullableByDefaultCompiledMode.Strong) { - registerNnbdMismatchLibrary( - libraryBuilder, messageAgnosticWithStrongDillLibrary); - } else { - registerNnbdMismatchLibrary( - libraryBuilder, messageAgnosticWithWeakDillLibrary); - } - } - break; } } } diff --git a/pkg/front_end/lib/src/kernel_generator_impl.dart b/pkg/front_end/lib/src/kernel_generator_impl.dart index 810be27434c..a4526fff4df 100644 --- a/pkg/front_end/lib/src/kernel_generator_impl.dart +++ b/pkg/front_end/lib/src/kernel_generator_impl.dart @@ -198,9 +198,6 @@ Future _buildInternal( case NnbdMode.Strong: compiledMode = NonNullableByDefaultCompiledMode.Strong; break; - case NnbdMode.Agnostic: - compiledMode = NonNullableByDefaultCompiledMode.Agnostic; - break; } if (kernelTarget.loader.hasInvalidNnbdModeLibrary) { compiledMode = NonNullableByDefaultCompiledMode.Invalid; diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml index d5d7dfe297e..48fd24d063d 100644 --- a/pkg/front_end/messages.yaml +++ b/pkg/front_end/messages.yaml @@ -1893,12 +1893,6 @@ WeakWithStrongDillLibrary: StrongWithWeakDillLibrary: problemMessage: "Loaded library is compiled with unsound null safety and cannot be used in compilation for sound null safety." -AgnosticWithStrongDillLibrary: - problemMessage: "Loaded library is compiled with sound null safety and cannot be used in compilation for agnostic null safety." - -AgnosticWithWeakDillLibrary: - problemMessage: "Loaded library is compiled with unsound null safety and cannot be used in compilation for agnostic null safety." - InvalidNnbdDillLibrary: problemMessage: "Trying to use library with invalid null safety." @@ -5889,9 +5883,6 @@ FinalPossiblyAssignedError: i = 0; } -NonAgnosticConstant: - problemMessage: "Constant value is not strong/weak mode agnostic." - CannotAssignToFinalVariable: problemMessage: "Can't assign to the final variable '#name'." script: | diff --git a/pkg/front_end/test/compile_platform_coverage.dart b/pkg/front_end/test/compile_platform_coverage.dart index b42effc664d..ff586f94d89 100644 --- a/pkg/front_end/test/compile_platform_coverage.dart +++ b/pkg/front_end/test/compile_platform_coverage.dart @@ -30,7 +30,7 @@ Future main(List arguments) async { "dart:core", "-Ddart.vm.product=false", "-Ddart.isVM=true", - "--nnbd-agnostic", + "--nnbd-strong", "--single-root-scheme=org-dartlang-sdk", "--single-root-base=.", "org-dartlang-sdk:///sdk/lib/libraries.json", diff --git a/pkg/front_end/test/fasta/testing/folder_options.dart b/pkg/front_end/test/fasta/testing/folder_options.dart index b8ed7adb10a..183359d96bf 100644 --- a/pkg/front_end/test/fasta/testing/folder_options.dart +++ b/pkg/front_end/test/fasta/testing/folder_options.dart @@ -26,7 +26,6 @@ const List