mirror of
https://github.com/dart-lang/sdk
synced 2024-10-03 00:29:50 +00:00
[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 <athom@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Jens Johansen <jensj@google.com>
This commit is contained in:
parent
d06d627c79
commit
c5cd8ff349
|
@ -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
|
||||
|
|
|
@ -241,28 +241,6 @@ Message _withArgumentsAccessError(String name) {
|
|||
);
|
||||
}
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const Code<Null> 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<Null> 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<Null> 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<Null> 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<Message Function(String character, int codePoint)>
|
||||
templateNonAsciiIdentifier =
|
||||
|
|
|
@ -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".
|
||||
|
|
|
@ -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<bool> nnbdStrongMode =
|
||||
const Option(Flags.nnbdStrongMode, const BoolValue(false));
|
||||
static const Option<bool> nnbdAgnosticMode =
|
||||
const Option(Flags.nnbdAgnosticMode, const BoolValue(false));
|
||||
static const Option<String> target = const Option(
|
||||
Flags.target, const StringValue(defaultValue: 'vm'),
|
||||
aliases: ["-t"]);
|
||||
|
|
|
@ -5,5 +5,4 @@
|
|||
enum NnbdMode {
|
||||
Strong,
|
||||
Weak,
|
||||
Agnostic,
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -172,15 +172,6 @@ class SetConstantBuilder extends _ListOrSetConstantBuilder<SetLiteral> {
|
|||
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<Constant> lastPart;
|
||||
if (parts.last is List<Constant>) {
|
||||
|
@ -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);
|
||||
|
|
|
@ -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<Constant?> {
|
||||
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<ConstantMapEntry>? 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<Constant>? 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<Constant>? 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<Constant>? 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<String, Constant>? named;
|
||||
for (MapEntry<String, Constant> entry in node.named.entries) {
|
||||
Constant? value = visitConstant(entry.value);
|
||||
if (value != null) {
|
||||
named ??= new Map<String, Constant>.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<DartType>? 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<Reference, Constant>? fieldValues;
|
||||
for (MapEntry<Reference, Constant> entry in node.fieldValues.entries) {
|
||||
Reference reference = entry.key;
|
||||
Constant? value = visitConstant(entry.value);
|
||||
if (value != null) {
|
||||
fieldValues ??= new Map<Reference, Constant>.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<DartType>? 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<DartType>? 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<Constant> {
|
|||
|
||||
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<Constant> {
|
|||
coreTypes.typeClass: true,
|
||||
};
|
||||
primitiveHashCodeCache = <Class, bool>{...primitiveEqualCache};
|
||||
_weakener = new ConstantWeakener(this);
|
||||
}
|
||||
|
||||
Map<String, String>? _supportedLibrariesCache;
|
||||
|
@ -2524,7 +2304,6 @@ class ConstantEvaluator implements ExpressionVisitor<Constant> {
|
|||
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<Constant> {
|
|||
List<DartType> convertTypes(List<DartType> 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<Constant> {
|
|||
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> {
|
|||
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<Constant> {
|
|||
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<Constant> {
|
|||
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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -450,10 +450,6 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
|
|||
library.nonNullableByDefaultCompiledMode =
|
||||
NonNullableByDefaultCompiledMode.Strong;
|
||||
break;
|
||||
case NnbdMode.Agnostic:
|
||||
library.nonNullableByDefaultCompiledMode =
|
||||
NonNullableByDefaultCompiledMode.Agnostic;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,9 +198,6 @@ Future<InternalCompilerResult> _buildInternal(
|
|||
case NnbdMode.Strong:
|
||||
compiledMode = NonNullableByDefaultCompiledMode.Strong;
|
||||
break;
|
||||
case NnbdMode.Agnostic:
|
||||
compiledMode = NonNullableByDefaultCompiledMode.Agnostic;
|
||||
break;
|
||||
}
|
||||
if (kernelTarget.loader.hasInvalidNnbdModeLibrary) {
|
||||
compiledMode = NonNullableByDefaultCompiledMode.Invalid;
|
||||
|
|
|
@ -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: |
|
||||
|
|
|
@ -30,7 +30,7 @@ Future<void> main(List<String> 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",
|
||||
|
|
|
@ -26,7 +26,6 @@ const List<Option> folderOptionsSpecification = [
|
|||
Options.forceStaticFieldLowering,
|
||||
Options.forceNoExplicitGetterCalls,
|
||||
Options.forceConstructorTearOffLowering,
|
||||
Options.nnbdAgnosticMode,
|
||||
Options.noDefines,
|
||||
noVerifyCmd,
|
||||
Options.target,
|
||||
|
@ -49,7 +48,6 @@ class SuiteFolderOptions {
|
|||
bool? forceStaticFieldLowering;
|
||||
bool? forceNoExplicitGetterCalls;
|
||||
int? forceConstructorTearOffLowering;
|
||||
bool nnbdAgnosticMode = false;
|
||||
bool noVerify = false;
|
||||
Map<String, String>? defines = {};
|
||||
String target = "vm";
|
||||
|
@ -62,7 +60,6 @@ class SuiteFolderOptions {
|
|||
forceStaticFieldLowering: forceStaticFieldLowering,
|
||||
forceNoExplicitGetterCalls: forceNoExplicitGetterCalls,
|
||||
forceConstructorTearOffLowering: forceConstructorTearOffLowering,
|
||||
nnbdAgnosticMode: nnbdAgnosticMode,
|
||||
defines: defines,
|
||||
noVerify: noVerify,
|
||||
target: target,
|
||||
|
@ -90,7 +87,6 @@ class SuiteFolderOptions {
|
|||
Options.forceNoExplicitGetterCalls.read(parsedOptions);
|
||||
forceConstructorTearOffLowering =
|
||||
Options.forceConstructorTearOffLowering.read(parsedOptions);
|
||||
nnbdAgnosticMode = Options.nnbdAgnosticMode.read(parsedOptions);
|
||||
defines = parsedOptions.defines;
|
||||
showOffsets = Options.showOffsets.read(parsedOptions);
|
||||
if (Options.noDefines.read(parsedOptions)) {
|
||||
|
@ -114,7 +110,6 @@ class SuiteFolderOptions {
|
|||
forceStaticFieldLowering: forceStaticFieldLowering,
|
||||
forceNoExplicitGetterCalls: forceNoExplicitGetterCalls,
|
||||
forceConstructorTearOffLowering: forceConstructorTearOffLowering,
|
||||
nnbdAgnosticMode: nnbdAgnosticMode,
|
||||
defines: defines,
|
||||
noVerify: noVerify,
|
||||
target: target,
|
||||
|
@ -167,7 +162,6 @@ class FolderOptions {
|
|||
final bool? forceStaticFieldLowering;
|
||||
final bool? forceNoExplicitGetterCalls;
|
||||
final int? forceConstructorTearOffLowering;
|
||||
final bool nnbdAgnosticMode;
|
||||
final Map<String, String>? defines;
|
||||
final bool noVerify;
|
||||
final String target;
|
||||
|
@ -181,7 +175,6 @@ class FolderOptions {
|
|||
this.forceStaticFieldLowering,
|
||||
this.forceNoExplicitGetterCalls,
|
||||
this.forceConstructorTearOffLowering,
|
||||
this.nnbdAgnosticMode = false,
|
||||
this.defines = const {},
|
||||
this.noVerify = false,
|
||||
this.target = "vm",
|
||||
|
|
|
@ -785,7 +785,7 @@ CompilationSetup createCompilationSetup(
|
|||
!isExperimentEnabled(ExperimentalFlag.nonNullable,
|
||||
explicitExperimentalFlags: experimentalFlags)
|
||||
? NnbdMode.Weak
|
||||
: (folderOptions.nnbdAgnosticMode ? NnbdMode.Agnostic : NnbdMode.Strong);
|
||||
: NnbdMode.Strong;
|
||||
List<Uri> inputs = <Uri>[description.uri];
|
||||
|
||||
CompilerOptions createCompilerOptions(
|
||||
|
|
|
@ -19,7 +19,6 @@ const Option<bool> fixNnbdReleaseVersion =
|
|||
const Option('--fix-nnbd-release-version', const BoolValue(false));
|
||||
|
||||
const List<Option> testOptionsSpecification = [
|
||||
Options.nnbdAgnosticMode,
|
||||
Options.nnbdStrongMode,
|
||||
Options.nnbdWeakMode,
|
||||
fixNnbdReleaseVersion,
|
||||
|
@ -45,14 +44,7 @@ class SuiteTestOptions {
|
|||
ParsedOptions.readOptionsFile(optionsFile.readAsStringSync());
|
||||
ParsedOptions parsedOptions =
|
||||
ParsedOptions.parse(arguments, testOptionsSpecification);
|
||||
if (Options.nnbdAgnosticMode.read(parsedOptions)) {
|
||||
nnbdMode = NnbdMode.Agnostic;
|
||||
}
|
||||
if (Options.nnbdStrongMode.read(parsedOptions)) {
|
||||
if (nnbdMode != null) {
|
||||
throw new UnsupportedError(
|
||||
'Nnbd mode $nnbdMode already specified.');
|
||||
}
|
||||
nnbdMode = NnbdMode.Strong;
|
||||
}
|
||||
if (Options.nnbdWeakMode.read(parsedOptions)) {
|
||||
|
|
|
@ -1926,21 +1926,6 @@ Result? checkNNBDSettings(Component component) {
|
|||
for (Library lib in component.libraries) {
|
||||
if (mode == lib.nonNullableByDefaultCompiledMode) continue;
|
||||
|
||||
if (mode == NonNullableByDefaultCompiledMode.Agnostic) {
|
||||
// Component says agnostic but the library isn't => Error!
|
||||
return new Result(
|
||||
null,
|
||||
NNBDModeMismatch,
|
||||
"Component mode was agnostic but ${lib.importUri} had mode "
|
||||
"${lib.nonNullableByDefaultCompiledMode}.");
|
||||
}
|
||||
|
||||
// Agnostic can be mixed with everything.
|
||||
if (lib.nonNullableByDefaultCompiledMode ==
|
||||
NonNullableByDefaultCompiledMode.Agnostic) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mode == NonNullableByDefaultCompiledMode.Strong ||
|
||||
lib.nonNullableByDefaultCompiledMode ==
|
||||
NonNullableByDefaultCompiledMode.Strong) {
|
||||
|
|
|
@ -71,7 +71,6 @@ const List<Option> optionSpecification = [
|
|||
Options.singleRootScheme,
|
||||
Options.nnbdWeakMode,
|
||||
Options.nnbdStrongMode,
|
||||
Options.nnbdAgnosticMode,
|
||||
Options.target,
|
||||
Options.verbose,
|
||||
Options.verbosity,
|
||||
|
@ -174,11 +173,7 @@ ProcessedOptions analyzeCommandLine(String programName,
|
|||
|
||||
final bool nnbdWeakMode = Options.nnbdWeakMode.read(parsedOptions);
|
||||
|
||||
final bool nnbdAgnosticMode = Options.nnbdAgnosticMode.read(parsedOptions);
|
||||
|
||||
final NnbdMode nnbdMode = nnbdAgnosticMode
|
||||
? NnbdMode.Agnostic
|
||||
: (nnbdWeakMode ? NnbdMode.Weak : NnbdMode.Strong);
|
||||
final NnbdMode nnbdMode = nnbdWeakMode ? NnbdMode.Weak : NnbdMode.Strong;
|
||||
|
||||
final bool enableUnscheduledExperiments =
|
||||
Options.enableUnscheduledExperiments.read(parsedOptions);
|
||||
|
@ -202,18 +197,6 @@ ProcessedOptions analyzeCommandLine(String programName,
|
|||
"'${Flags.nnbdWeakMode}'.");
|
||||
}
|
||||
|
||||
if (nnbdStrongMode && nnbdAgnosticMode) {
|
||||
return throw new CommandLineProblem.deprecated(
|
||||
"Can't specify both '${Flags.nnbdStrongMode}' and "
|
||||
"'${Flags.nnbdAgnosticMode}'.");
|
||||
}
|
||||
|
||||
if (nnbdWeakMode && nnbdAgnosticMode) {
|
||||
return throw new CommandLineProblem.deprecated(
|
||||
"Can't specify both '${Flags.nnbdWeakMode}' and "
|
||||
"'${Flags.nnbdAgnosticMode}'.");
|
||||
}
|
||||
|
||||
FileSystem fileSystem = StandardFileSystem.instance;
|
||||
if (singleRootScheme != null) {
|
||||
fileSystem = new SchemeBasedFileSystem({
|
||||
|
|
|
@ -268,7 +268,7 @@ abstract class Annotatable extends TreeNode {
|
|||
// LIBRARIES and CLASSES
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
enum NonNullableByDefaultCompiledMode { Strong, Weak, Agnostic, Invalid }
|
||||
enum NonNullableByDefaultCompiledMode { Strong, Weak, Invalid }
|
||||
|
||||
class Library extends NamedNode
|
||||
implements Annotatable, Comparable<Library>, FileUriNode {
|
||||
|
@ -310,7 +310,6 @@ class Library extends NamedNode
|
|||
bool bit2 = (flags & NonNullableByDefaultModeBit2) != 0;
|
||||
if (!bit1 && !bit2) return NonNullableByDefaultCompiledMode.Strong;
|
||||
if (bit1 && !bit2) return NonNullableByDefaultCompiledMode.Weak;
|
||||
if (bit1 && bit2) return NonNullableByDefaultCompiledMode.Agnostic;
|
||||
if (!bit1 && bit2) return NonNullableByDefaultCompiledMode.Invalid;
|
||||
throw new StateError("Unused bit-pattern for compilation mode");
|
||||
}
|
||||
|
@ -326,10 +325,6 @@ class Library extends NamedNode
|
|||
flags = (flags | NonNullableByDefaultModeBit1) &
|
||||
~NonNullableByDefaultModeBit2;
|
||||
break;
|
||||
case NonNullableByDefaultCompiledMode.Agnostic:
|
||||
flags = (flags | NonNullableByDefaultModeBit1) |
|
||||
NonNullableByDefaultModeBit2;
|
||||
break;
|
||||
case NonNullableByDefaultCompiledMode.Invalid:
|
||||
flags = (flags & ~NonNullableByDefaultModeBit1) |
|
||||
NonNullableByDefaultModeBit2;
|
||||
|
|
|
@ -4436,14 +4436,5 @@ NonNullableByDefaultCompiledMode mergeCompilationModeOrThrow(
|
|||
return b;
|
||||
}
|
||||
|
||||
if (a == NonNullableByDefaultCompiledMode.Agnostic) {
|
||||
return b;
|
||||
}
|
||||
if (b == NonNullableByDefaultCompiledMode.Agnostic) {
|
||||
// Keep as-is.
|
||||
return a;
|
||||
}
|
||||
|
||||
// Mixed mode where agnostic isn't involved.
|
||||
throw new CompilationModeError("Mixed compilation mode found: $a and $b");
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ void main() {
|
|||
const List<NonNullableByDefaultCompiledMode> modes = const [
|
||||
NonNullableByDefaultCompiledMode.Weak,
|
||||
NonNullableByDefaultCompiledMode.Strong,
|
||||
NonNullableByDefaultCompiledMode.Agnostic,
|
||||
];
|
||||
|
||||
int combination = 0;
|
||||
|
@ -128,18 +127,13 @@ void main() {
|
|||
|
||||
bool isOK(NonNullableByDefaultCompiledMode c1Mode,
|
||||
NonNullableByDefaultCompiledMode c2Mode) {
|
||||
if (c1Mode == c2Mode) return true;
|
||||
if (c1Mode == NonNullableByDefaultCompiledMode.Agnostic) return true;
|
||||
if (c2Mode == NonNullableByDefaultCompiledMode.Agnostic) return true;
|
||||
return false;
|
||||
return c1Mode == c2Mode;
|
||||
}
|
||||
|
||||
NonNullableByDefaultCompiledMode verifyOK(
|
||||
NonNullableByDefaultCompiledMode c1Mode,
|
||||
NonNullableByDefaultCompiledMode c2Mode) {
|
||||
if (isOK(c1Mode, c2Mode)) {
|
||||
if (c1Mode == NonNullableByDefaultCompiledMode.Agnostic) return c2Mode;
|
||||
if (c2Mode == NonNullableByDefaultCompiledMode.Agnostic) return c1Mode;
|
||||
return c1Mode;
|
||||
}
|
||||
throw "Not OK combination: $c1Mode and $c2Mode";
|
||||
|
|
|
@ -35,7 +35,6 @@ void main() {
|
|||
for (NonNullableByDefaultCompiledMode nonNullableByDefaultCompiledMode in [
|
||||
NonNullableByDefaultCompiledMode.Weak,
|
||||
NonNullableByDefaultCompiledMode.Strong,
|
||||
NonNullableByDefaultCompiledMode.Agnostic,
|
||||
]) {
|
||||
combination++;
|
||||
print("Checking combination #$combination ("
|
||||
|
|
|
@ -85,7 +85,7 @@ $checkout/tools/sdks/dart-sdk/bin/dart \
|
|||
dart:core \
|
||||
-Ddart.vm.product=false \
|
||||
-Ddart.isVM=true \
|
||||
--nnbd-agnostic \
|
||||
--nnbd-strong \
|
||||
--single-root-scheme=org-dartlang-sdk \
|
||||
--single-root-base=$checkout/ \
|
||||
org-dartlang-sdk:///sdk/lib/libraries.json \
|
||||
|
@ -96,7 +96,7 @@ $checkout/tools/sdks/dart-sdk/bin/dart \
|
|||
$checkout/tools/sdks/dart-sdk/bin/dart \
|
||||
--packages=$checkout/.dart_tool/package_config.json \
|
||||
$checkout/pkg/front_end/tool/_fasta/compile_platform.dart \
|
||||
--nnbd-agnostic \
|
||||
--nnbd-strong \
|
||||
--target=flutter \
|
||||
dart:core \
|
||||
--single-root-scheme=org-dartlang-sdk \
|
||||
|
|
Loading…
Reference in a new issue