Version 2.10.0-146.0.dev
Merge commit 'e20a5d171c712b1a1834d447ff8d44f0f31c4d91' into 'dev'
diff --git a/pkg/analysis_server/lib/src/services/completion/token_details/token_detail_builder.dart b/pkg/analysis_server/lib/src/services/completion/token_details/token_detail_builder.dart
index 3be9cd3..44c3ad9 100644
--- a/pkg/analysis_server/lib/src/services/completion/token_details/token_detail_builder.dart
+++ b/pkg/analysis_server/lib/src/services/completion/token_details/token_detail_builder.dart
@@ -115,7 +115,7 @@
} else if (type is InterfaceType) {
Element element = type.element;
if (element == null || element.isSynthetic) {
- assert(false, "untested branch may print nullable types wrong");
+ assert(false, 'untested branch may print nullable types wrong');
// TODO: test this, use the the library's nullability (not tracked yet).
buffer.write(type.getDisplayString(withNullability: false));
} else {
diff --git a/pkg/analyzer/lib/src/dart/constant/compute.dart b/pkg/analyzer/lib/src/dart/constant/compute.dart
index 229cb78..e81acbb 100644
--- a/pkg/analyzer/lib/src/dart/constant/compute.dart
+++ b/pkg/analyzer/lib/src/dart/constant/compute.dart
@@ -77,12 +77,7 @@
}
ConstantEvaluationEngine _getEvaluationEngine(_ConstantNode node) {
- var library = node.constant.library;
- return ConstantEvaluationEngine(
- library.typeProvider,
- declaredVariables,
- typeSystem: library.typeSystem,
- );
+ return ConstantEvaluationEngine(declaredVariables);
}
_ConstantNode _getNode(ConstantEvaluationTarget constant) {
diff --git a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
index e6ebdd3..ad1100b 100644
--- a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
+++ b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
@@ -78,9 +78,7 @@
: _constantUpdate2018Enabled =
featureSet.isEnabled(Feature.constant_update_2018),
_intType = _typeProvider.intType,
- _evaluationEngine = ConstantEvaluationEngine(
- _typeProvider, declaredVariables,
- typeSystem: _typeSystem);
+ _evaluationEngine = ConstantEvaluationEngine(declaredVariables);
bool get _isNonNullableByDefault => _currentLibrary.isNonNullableByDefault;
@@ -141,6 +139,7 @@
ConstantVisitor constantVisitor =
ConstantVisitor(_evaluationEngine, _currentLibrary, _errorReporter);
_evaluationEngine.evaluateConstructorCall(
+ _currentLibrary,
node,
node.argumentList.arguments,
constructor,
@@ -406,6 +405,12 @@
}
}
+ /// Check if the object [obj] matches the type [type] according to runtime
+ /// type checking rules.
+ bool _runtimeTypeMatch(DartObjectImpl obj, DartType type) {
+ return _evaluationEngine.runtimeTypeMatch(_currentLibrary, obj, type);
+ }
+
/// Validate that the given expression is a compile time constant. Return the
/// value of the compile time constant, or `null` if the expression is not a
/// compile time constant.
@@ -789,7 +794,7 @@
}
bool _validateListExpression(Expression expression, DartObjectImpl value) {
- if (!verifier._evaluationEngine.runtimeTypeMatch(value, listElementType)) {
+ if (!verifier._runtimeTypeMatch(value, listElementType)) {
verifier._errorReporter.reportErrorForNode(
CompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE,
expression,
@@ -866,7 +871,7 @@
if (keyValue != null) {
var keyType = keyValue.type;
- if (!verifier._evaluationEngine.runtimeTypeMatch(keyValue, mapKeyType)) {
+ if (!verifier._runtimeTypeMatch(keyValue, mapKeyType)) {
verifier._errorReporter.reportErrorForNode(
CompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE,
keyExpression,
@@ -895,8 +900,7 @@
}
if (valueValue != null) {
- if (!verifier._evaluationEngine
- .runtimeTypeMatch(valueValue, mapValueType)) {
+ if (!verifier._runtimeTypeMatch(valueValue, mapValueType)) {
verifier._errorReporter.reportErrorForNode(
CompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE,
valueExpression,
@@ -944,7 +948,7 @@
}
bool _validateSetExpression(Expression expression, DartObjectImpl value) {
- if (!verifier._evaluationEngine.runtimeTypeMatch(value, setElementType)) {
+ if (!verifier._runtimeTypeMatch(value, setElementType)) {
verifier._errorReporter.reportErrorForNode(
CompileTimeErrorCode.SET_ELEMENT_TYPE_NOT_ASSIGNABLE,
expression,
diff --git a/pkg/analyzer/lib/src/dart/constant/evaluation.dart b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
index cd54de6..33034f0 100644
--- a/pkg/analyzer/lib/src/dart/constant/evaluation.dart
+++ b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
@@ -15,7 +15,6 @@
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
-import 'package:analyzer/dart/element/type_system.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/dart/constant/from_environment_evaluator.dart';
@@ -63,58 +62,15 @@
static final RegExp _PUBLIC_SYMBOL_PATTERN = RegExp(
"^(?:$_OPERATOR_RE\$|$_PUBLIC_IDENTIFIER_RE(?:=?\$|[.](?!\$)))+?\$");
- /// The type provider used to access the known types.
- final TypeProvider typeProvider;
+ /// The set of variables declared on the command line using '-D'.
+ final DeclaredVariables _declaredVariables;
- /// The type system. This is used to guess the types of constants when their
- /// exact value is unknown.
- final TypeSystemImpl typeSystem;
-
- /// The helper for evaluating variables declared on the command line
- /// using '-D', and represented as [DeclaredVariables].
- FromEnvironmentEvaluator _fromEnvironmentEvaluator;
-
- /// Validator used to verify correct dependency analysis when running unit
- /// tests.
- final ConstantEvaluationValidator validator;
-
- /// Initialize a newly created [ConstantEvaluationEngine]. The [typeProvider]
- /// is used to access known types. [_fromEnvironmentEvaluator] is the set of
- /// variables declared on the command line using '-D'. The [validator], if
- /// given, is used to verify correct dependency analysis when running unit
- /// tests.
- ConstantEvaluationEngine(
- TypeProvider typeProvider, DeclaredVariables declaredVariables,
- {ConstantEvaluationValidator validator,
- TypeSystem typeSystem,
- // TODO(brianwilkerson) Remove the unused parameter `forAnalysisDriver`.
- @deprecated bool forAnalysisDriver})
- : typeProvider = typeProvider,
- validator = validator ?? ConstantEvaluationValidator_ForProduction(),
- typeSystem = typeSystem ??
- TypeSystemImpl(
- implicitCasts: true,
- isNonNullableByDefault: false,
- strictInference: false,
- typeProvider: typeProvider,
- ) {
- _fromEnvironmentEvaluator = FromEnvironmentEvaluator(
- typeSystem,
- declaredVariables,
- );
- }
-
- bool get _isNonNullableByDefault {
- return typeSystem.isNonNullableByDefault;
- }
-
- DartObjectImpl get _nullObject {
- return DartObjectImpl(
- typeSystem,
- typeProvider.nullType,
- NullState.NULL_STATE,
- );
- }
+ /// Initialize a newly created [ConstantEvaluationEngine].
+ ///
+ /// [declaredVariables] is the set of variables declared on the command
+ /// line using '-D'.
+ ConstantEvaluationEngine(DeclaredVariables declaredVariables)
+ : _declaredVariables = declaredVariables;
/// Check that the arguments to a call to fromEnvironment() are correct. The
/// [arguments] are the AST nodes of the arguments. The [argumentValues] are
@@ -124,6 +80,7 @@
/// "defaultValue" is always allowed to be null. Return `true` if the
/// arguments are correct, `false` if there is an error.
bool checkFromEnvironmentArguments(
+ LibraryElementImpl library,
NodeList<Expression> arguments,
List<DartObjectImpl> argumentValues,
Map<String, DartObjectImpl> namedArgumentValues,
@@ -135,7 +92,7 @@
if (arguments[0] is NamedExpression) {
return false;
}
- if (argumentValues[0].type != typeProvider.stringType) {
+ if (argumentValues[0].type != library.typeProvider.stringType) {
return false;
}
if (argumentCount == 2) {
@@ -147,7 +104,7 @@
ParameterizedType defaultValueType =
namedArgumentValues[_DEFAULT_VALUE_PARAM].type;
if (!(defaultValueType == expectedDefaultValueType ||
- defaultValueType == typeProvider.nullType)) {
+ defaultValueType == library.typeProvider.nullType)) {
return false;
}
} else {
@@ -163,6 +120,7 @@
/// values of the named arguments. Return `true` if the arguments are correct,
/// `false` if there is an error.
bool checkSymbolArguments(
+ LibraryElementImpl library,
NodeList<Expression> arguments,
List<DartObjectImpl> argumentValues,
Map<String, DartObjectImpl> namedArgumentValues) {
@@ -172,7 +130,7 @@
if (arguments[0] is NamedExpression) {
return false;
}
- if (argumentValues[0].type != typeProvider.stringType) {
+ if (argumentValues[0].type != library.typeProvider.stringType) {
return false;
}
String name = argumentValues[0].toStringValue();
@@ -181,13 +139,12 @@
/// Compute the constant value associated with the given [constant].
void computeConstantValue(ConstantEvaluationTarget constant) {
- validator.beforeComputeValue(constant);
-
if (constant is Element) {
var element = constant as Element;
constant = element.declaration as ConstantEvaluationTarget;
}
+ var library = constant.library;
if (constant is ParameterElementImpl) {
if (constant.isOptional) {
Expression defaultValue = constant.constantInitializer;
@@ -196,14 +153,16 @@
ErrorReporter errorReporter = ErrorReporter(
errorListener,
constant.source,
- isNonNullableByDefault: _isNonNullableByDefault,
+ isNonNullableByDefault: library.isNonNullableByDefault,
);
DartObjectImpl dartObject = defaultValue
- .accept(ConstantVisitor(this, constant.library, errorReporter));
+ .accept(ConstantVisitor(this, library, errorReporter));
constant.evaluationResult =
EvaluationResultImpl(dartObject, errorListener.errors);
} else {
- constant.evaluationResult = EvaluationResultImpl(_nullObject);
+ constant.evaluationResult = EvaluationResultImpl(
+ _nullObject(library),
+ );
}
}
} else if (constant is VariableElementImpl) {
@@ -213,16 +172,16 @@
ErrorReporter errorReporter = ErrorReporter(
errorListener,
constant.source,
- isNonNullableByDefault: _isNonNullableByDefault,
+ isNonNullableByDefault: library.isNonNullableByDefault,
);
DartObjectImpl dartObject = constantInitializer
- .accept(ConstantVisitor(this, constant.library, errorReporter));
+ .accept(ConstantVisitor(this, library, errorReporter));
// Only check the type for truly const declarations (don't check final
// fields with initializers, since their types may be generic. The type
// of the final field will be checked later, when the constructor is
// invoked).
if (dartObject != null && constant.isConst) {
- if (!runtimeTypeMatch(dartObject, constant.type)) {
+ if (!runtimeTypeMatch(library, dartObject, constant.type)) {
// TODO(brianwilkerson) This should not be reported if
// CompileTimeErrorCode.INVALID_ASSIGNMENT has already been
// reported (that is, if the static types are also wrong).
@@ -267,11 +226,12 @@
ErrorReporter errorReporter = ErrorReporter(
errorListener,
constant.source,
- isNonNullableByDefault: _isNonNullableByDefault,
+ isNonNullableByDefault: library.isNonNullableByDefault,
);
ConstantVisitor constantVisitor =
- ConstantVisitor(this, constant.library, errorReporter);
+ ConstantVisitor(this, library, errorReporter);
DartObjectImpl result = evaluateConstructorCall(
+ library,
constNode,
constNode.arguments.arguments,
element,
@@ -415,6 +375,7 @@
}
DartObjectImpl evaluateConstructorCall(
+ LibraryElementImpl library,
AstNode node,
List<Expression> arguments,
ConstructorElement constructor,
@@ -439,7 +400,7 @@
// circularities (e.g. "compile-time constant expression depends on
// itself")
return DartObjectImpl.validWithUnknownValue(
- typeSystem,
+ library.typeSystem,
constructor.returnType,
);
}
@@ -471,46 +432,57 @@
);
constructor = followConstantRedirectionChain(constructor);
- InterfaceType definingClass = constructor.returnType;
+ InterfaceType definingType = constructor.returnType;
+ ClassElement definingClass = constructor.enclosingElement;
if (constructor.isFactory) {
// We couldn't find a non-factory constructor.
// See if it's because we reached an external const factory constructor
// that we can emulate.
if (constructor.name == "fromEnvironment") {
if (!checkFromEnvironmentArguments(
- arguments, argumentValues, namedValues, definingClass)) {
+ library, arguments, argumentValues, namedValues, definingType)) {
errorReporter.reportErrorForNode(
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, node);
return null;
}
String variableName =
argumentCount < 1 ? null : argumentValues[0].toStringValue();
- if (definingClass == typeProvider.boolType) {
- return _fromEnvironmentEvaluator.getBool2(
- variableName, namedValues, constructor);
- } else if (definingClass == typeProvider.intType) {
- return _fromEnvironmentEvaluator.getInt2(
- variableName, namedValues, constructor);
- } else if (definingClass == typeProvider.stringType) {
- return _fromEnvironmentEvaluator.getString2(
- variableName, namedValues, constructor);
+ if (definingClass == library.typeProvider.boolElement) {
+ return FromEnvironmentEvaluator(
+ library.typeSystem,
+ _declaredVariables,
+ ).getBool2(variableName, namedValues, constructor);
+ } else if (definingClass == library.typeProvider.intElement) {
+ return FromEnvironmentEvaluator(
+ library.typeSystem,
+ _declaredVariables,
+ ).getInt2(variableName, namedValues, constructor);
+ } else if (definingClass == library.typeProvider.stringElement) {
+ return FromEnvironmentEvaluator(
+ library.typeSystem,
+ _declaredVariables,
+ ).getString2(variableName, namedValues, constructor);
}
} else if (constructor.name == 'hasEnvironment' &&
- definingClass == typeProvider.boolType) {
+ definingClass == library.typeProvider.boolElement) {
var name = argumentCount < 1 ? null : argumentValues[0].toStringValue();
- return _fromEnvironmentEvaluator.hasEnvironment(name);
+ return FromEnvironmentEvaluator(
+ library.typeSystem,
+ _declaredVariables,
+ ).hasEnvironment(name);
} else if (constructor.name == "" &&
- definingClass == typeProvider.symbolType &&
+ definingClass == library.typeProvider.symbolElement &&
argumentCount == 1) {
- if (!checkSymbolArguments(arguments, argumentValues, namedValues)) {
+ if (!checkSymbolArguments(
+ library, arguments, argumentValues, namedValues)) {
errorReporter.reportErrorForNode(
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, node);
return null;
}
String argumentValue = argumentValues[0].toStringValue();
return DartObjectImpl(
- typeSystem,
- definingClass,
+ library.typeSystem,
+ definingType,
SymbolState(argumentValue),
);
}
@@ -520,10 +492,12 @@
// In the former case, the best we can do is consider it an unknown value.
// In the latter case, the error has already been reported, so considering
// it an unknown value will suppress further errors.
- return DartObjectImpl.validWithUnknownValue(typeSystem, definingClass);
+ return DartObjectImpl.validWithUnknownValue(
+ library.typeSystem,
+ definingType,
+ );
}
ConstructorElementImpl constructorBase = constructor.declaration;
- validator.beforeGetConstantInitializers(constructorBase);
List<ConstructorInitializer> initializers =
constructorBase.constantInitializers;
if (initializers == null) {
@@ -532,7 +506,10 @@
// const instance using a non-const constructor, or the node we're
// visiting is involved in a cycle). The error has already been reported,
// so consider it an unknown value to suppress further errors.
- return DartObjectImpl.validWithUnknownValue(typeSystem, definingClass);
+ return DartObjectImpl.validWithUnknownValue(
+ library.typeSystem,
+ definingType,
+ );
}
var fieldMap = HashMap<String, DartObjectImpl>();
@@ -546,7 +523,7 @@
var externalErrorReporter = ErrorReporter(
externalErrorListener,
constructor.source,
- isNonNullableByDefault: _isNonNullableByDefault,
+ isNonNullableByDefault: library.isNonNullableByDefault,
);
// Start with final fields that are initialized at their declaration site.
@@ -556,8 +533,6 @@
if ((field.isFinal || field.isConst) &&
!field.isStatic &&
field is ConstFieldElementImpl) {
- validator.beforeGetFieldEvaluationResult(field);
-
DartObjectImpl fieldValue = field.evaluationResult?.value;
// It is possible that the evaluation result is null.
@@ -569,7 +544,8 @@
// Match the value and the type.
DartType fieldType =
FieldMember.from(field, constructor.returnType).type;
- if (fieldValue != null && !runtimeTypeMatch(fieldValue, fieldType)) {
+ if (fieldValue != null &&
+ !runtimeTypeMatch(library, fieldValue, fieldType)) {
errorReporter.reportErrorForNode(
CompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
node,
@@ -603,18 +579,16 @@
if (argumentValue == null && baseParameter is ParameterElementImpl) {
// The parameter is an optional positional parameter for which no value
// was provided, so use the default value.
- validator.beforeGetParameterDefault(baseParameter);
-
EvaluationResultImpl evaluationResult = baseParameter.evaluationResult;
if (evaluationResult == null) {
// No default was provided, so the default value is null.
- argumentValue = _nullObject;
+ argumentValue = _nullObject(library);
} else if (evaluationResult.value != null) {
argumentValue = evaluationResult.value;
}
}
if (argumentValue != null) {
- if (!runtimeTypeMatch(argumentValue, parameter.type)) {
+ if (!runtimeTypeMatch(library, argumentValue, parameter.type)) {
errorReporter.reportErrorForNode(
CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
errorTarget,
@@ -628,7 +602,7 @@
// We've already checked that the argument can be assigned to the
// parameter; we also need to check that it can be assigned to
// the field.
- if (!runtimeTypeMatch(argumentValue, fieldType)) {
+ if (!runtimeTypeMatch(library, argumentValue, fieldType)) {
errorReporter.reportErrorForNode(
CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
errorTarget,
@@ -652,7 +626,7 @@
constructor.library,
externalErrorReporter,
lexicalEnvironment: parameterMap,
- substitution: Substitution.fromInterfaceType(definingClass),
+ substitution: Substitution.fromInterfaceType(definingType),
);
String superName;
NodeList<Expression> superArguments;
@@ -669,10 +643,10 @@
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, node);
}
fieldMap[fieldName] = evaluationResult;
- PropertyAccessorElement getter = definingClass.getGetter(fieldName);
+ PropertyAccessorElement getter = definingType.getGetter(fieldName);
if (getter != null) {
PropertyInducingElement field = getter.variable;
- if (!runtimeTypeMatch(evaluationResult, field.type)) {
+ if (!runtimeTypeMatch(library, evaluationResult, field.type)) {
errorReporter.reportErrorForNode(
CompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
node,
@@ -695,9 +669,10 @@
ConstructorElement constructor = initializer.staticElement;
if (constructor != null && constructor.isConst) {
// Instantiate the constructor with the in-scope type arguments.
- constructor = ConstructorMember.from(constructor, definingClass);
+ constructor = ConstructorMember.from(constructor, definingType);
DartObjectImpl result = evaluateConstructorCall(
+ library,
node,
initializer.argumentList.arguments,
constructor,
@@ -727,7 +702,7 @@
}
}
// Evaluate explicit or implicit call to super().
- InterfaceType superclass = definingClass.superclass;
+ InterfaceType superclass = definingType.superclass;
if (superclass != null && !superclass.isDartCoreObject) {
ConstructorElement superConstructor =
superclass.lookUpConstructor(superName, constructor.library);
@@ -738,7 +713,7 @@
superConstructor = Member.legacy(superConstructor);
}
- evaluateSuperConstructorCall(node, fieldMap, superConstructor,
+ evaluateSuperConstructorCall(library, node, fieldMap, superConstructor,
superArguments, initializerVisitor, externalErrorReporter);
}
}
@@ -747,13 +722,14 @@
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, node);
}
return DartObjectImpl(
- typeSystem,
- definingClass,
+ library.typeSystem,
+ definingType,
GenericState(fieldMap, invocation: invocation),
);
}
void evaluateSuperConstructorCall(
+ LibraryElementImpl library,
AstNode node,
Map<String, DartObjectImpl> fieldMap,
ConstructorElement superConstructor,
@@ -761,7 +737,7 @@
ConstantVisitor initializerVisitor,
ErrorReporter errorReporter) {
if (superConstructor != null && superConstructor.isConst) {
- DartObjectImpl evaluationResult = evaluateConstructorCall(node,
+ DartObjectImpl evaluationResult = evaluateConstructorCall(library, node,
superArguments, superConstructor, initializerVisitor, errorReporter);
if (evaluationResult != null) {
fieldMap[GenericState.SUPERCLASS_FIELD] = evaluationResult;
@@ -805,14 +781,16 @@
/// compile-time constant because it references at least one of the constants
/// in the given [cycle], each of which directly or indirectly references the
/// constant.
- void generateCycleError(Iterable<ConstantEvaluationTarget> cycle,
- ConstantEvaluationTarget constant) {
+ void generateCycleError(
+ Iterable<ConstantEvaluationTarget> cycle,
+ ConstantEvaluationTarget constant,
+ ) {
if (constant is VariableElement) {
RecordingErrorListener errorListener = RecordingErrorListener();
ErrorReporter errorReporter = ErrorReporter(
errorListener,
constant.source,
- isNonNullableByDefault: _isNonNullableByDefault,
+ isNonNullableByDefault: constant.library.isNonNullableByDefault,
);
// TODO(paulberry): It would be really nice if we could extract enough
// information from the 'cycle' argument to provide the user with a
@@ -841,6 +819,7 @@
if (!constructor.isFactory) {
return null;
}
+ var typeProvider = constructor.library.typeProvider;
if (constructor.enclosingElement == typeProvider.symbolElement) {
// The dart:core.Symbol has a const factory constructor that redirects
// to dart:_internal.Symbol. That in turn redirects to an external
@@ -866,12 +845,24 @@
/// Check if the object [obj] matches the type [type] according to runtime
/// type checking rules.
- bool runtimeTypeMatch(DartObjectImpl obj, DartType type) {
+ bool runtimeTypeMatch(
+ LibraryElementImpl library,
+ DartObjectImpl obj,
+ DartType type,
+ ) {
if (obj.isNull) {
return true;
}
var objType = obj.type;
- return typeSystem.isSubtypeOf2(objType, type);
+ return library.typeSystem.isSubtypeOf2(objType, type);
+ }
+
+ DartObjectImpl _nullObject(LibraryElementImpl library) {
+ return DartObjectImpl(
+ library.typeSystem,
+ library.typeProvider.nullType,
+ NullState.NULL_STATE,
+ );
}
/// Determine whether the given string is a valid name for a public symbol
@@ -979,11 +970,14 @@
Substitution substitution,
}) : _lexicalEnvironment = lexicalEnvironment,
_substitution = substitution {
- _dartObjectComputer = DartObjectComputer(_errorReporter, evaluationEngine);
+ _dartObjectComputer = DartObjectComputer(
+ _library.typeSystem,
+ _errorReporter,
+ );
}
/// Convenience getter to gain access to the [evaluationEngine]'s type system.
- TypeSystemImpl get typeSystem => evaluationEngine.typeSystem;
+ TypeSystemImpl get typeSystem => _library.typeSystem;
bool get _isEnabledConstantUpdate2018 {
return _library.featureSet.isEnabled(Feature.constant_update_2018);
@@ -993,7 +987,7 @@
/// Convenience getter to gain access to the [evaluationEngine]'s type
/// provider.
- TypeProvider get _typeProvider => evaluationEngine.typeProvider;
+ TypeProvider get _typeProvider => _library.typeProvider;
@override
DartObjectImpl visitAdjacentStrings(AdjacentStrings node) {
@@ -1189,8 +1183,8 @@
return null;
}
- return evaluationEngine.evaluateConstructorCall(
- node, node.argumentList.arguments, constructor, this, _errorReporter);
+ return evaluationEngine.evaluateConstructorCall(_library, node,
+ node.argumentList.arguments, constructor, this, _errorReporter);
}
@override
@@ -1302,7 +1296,7 @@
@override
DartObjectImpl visitNullLiteral(NullLiteral node) {
- return evaluationEngine._nullObject;
+ return evaluationEngine._nullObject(_library);
}
@override
@@ -1726,7 +1720,7 @@
/// [identifier] is "length".
bool _isStringLength(
DartObjectImpl targetResult, SimpleIdentifier identifier) {
- if (targetResult == null || targetResult.type != _typeProvider.stringType) {
+ if (targetResult?.type?.element != _typeProvider.stringElement) {
return false;
}
return identifier.name == 'length' &&
@@ -1755,23 +1749,19 @@
if (expressionValue != null) {
return expressionValue;
}
- return evaluationEngine._nullObject;
+ return evaluationEngine._nullObject(_library);
}
}
/// A utility class that contains methods for manipulating instances of a Dart
/// class and for collecting errors during evaluation.
class DartObjectComputer {
+ final TypeSystemImpl _typeSystem;
+
/// The error reporter that we are using to collect errors.
final ErrorReporter _errorReporter;
- /// The evaluation engine used to access the type system, and type provider.
- final ConstantEvaluationEngine _evaluationEngine;
-
- DartObjectComputer(this._errorReporter, this._evaluationEngine);
-
- /// Convenience getter to gain access to the [evaluationEngine]'s type system.
- TypeSystem get _typeSystem => _evaluationEngine.typeSystem;
+ DartObjectComputer(this._typeSystem, this._errorReporter);
DartObjectImpl add(BinaryExpression node, DartObjectImpl leftOperand,
DartObjectImpl rightOperand) {
diff --git a/pkg/analyzer/lib/src/generated/constant.dart b/pkg/analyzer/lib/src/generated/constant.dart
index e79ed4e..cb4d7fb 100644
--- a/pkg/analyzer/lib/src/generated/constant.dart
+++ b/pkg/analyzer/lib/src/generated/constant.dart
@@ -9,8 +9,6 @@
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/dart/constant/evaluation.dart';
import 'package:analyzer/src/dart/constant/value.dart';
-import 'package:analyzer/src/dart/element/type_provider.dart';
-import 'package:analyzer/src/dart/element/type_system.dart' show TypeSystemImpl;
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/engine.dart' show RecordingErrorListener;
import 'package:analyzer/src/generated/source.dart' show Source;
@@ -108,20 +106,17 @@
/// types.
ConstantEvaluator(this._source, LibraryElement library) : _library = library;
- TypeProviderImpl get _typeProvider => _library.typeProvider;
-
- TypeSystemImpl get _typeSystem => _library.typeSystem;
-
EvaluationResult evaluate(Expression expression) {
RecordingErrorListener errorListener = RecordingErrorListener();
ErrorReporter errorReporter = ErrorReporter(
errorListener,
_source,
- isNonNullableByDefault: _typeSystem.isNonNullableByDefault,
+ isNonNullableByDefault: _library.isNonNullableByDefault,
);
DartObjectImpl result = expression.accept(ConstantVisitor(
- ConstantEvaluationEngine(_typeProvider, DeclaredVariables(),
- typeSystem: _typeSystem),
+ ConstantEvaluationEngine(
+ DeclaredVariables(),
+ ),
_library,
errorReporter));
List<AnalysisError> errors = errorListener.errors;
diff --git a/pkg/analyzer/lib/src/lint/linter.dart b/pkg/analyzer/lib/src/lint/linter.dart
index 0f81810..2c8a521 100644
--- a/pkg/analyzer/lib/src/lint/linter.dart
+++ b/pkg/analyzer/lib/src/lint/linter.dart
@@ -5,6 +5,7 @@
import 'dart:io';
import 'package:analyzer/dart/analysis/declared_variables.dart';
+import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/constant/value.dart';
@@ -267,6 +268,9 @@
/// Return the result of evaluating the given expression.
LinterConstantEvaluationResult evaluateConstant(Expression node);
+ /// Return `true` if the [feature] is enabled in the library being linted.
+ bool isEnabled(Feature feature);
+
/// Resolve the name `id` or `id=` (if [setter] is `true`) an the location
/// of the [node], according to the "16.35 Lexical Lookup" of the language
/// specification.
@@ -354,11 +358,7 @@
);
var visitor = ConstantVisitor(
- ConstantEvaluationEngine(
- typeProvider,
- declaredVariables,
- typeSystem: typeSystem,
- ),
+ ConstantEvaluationEngine(declaredVariables),
libraryElement,
errorReporter,
);
@@ -368,6 +368,10 @@
}
@override
+ bool isEnabled(Feature feature) =>
+ currentUnit.unit.declaredElement.library.featureSet.isEnabled(feature);
+
+ @override
LinterNameInScopeResolutionResult resolveNameInScope(
String id, bool setter, AstNode node) {
Scope scope;
diff --git a/pkg/analyzer/test/src/dart/constant/evaluation_test.dart b/pkg/analyzer/test/src/dart/constant/evaluation_test.dart
index 1c5816f..cb7aa88 100644
--- a/pkg/analyzer/test/src/dart/constant/evaluation_test.dart
+++ b/pkg/analyzer/test/src/dart/constant/evaluation_test.dart
@@ -318,9 +318,7 @@
DartObjectImpl result = expression.accept(
ConstantVisitor(
ConstantEvaluationEngine(
- typeProvider,
DeclaredVariables.fromMap(declaredVariables),
- typeSystem: this.result.typeSystem,
),
this.result.libraryElement,
errorReporter,
diff --git a/pkg/analyzer/test/src/services/available_declarations_test.dart b/pkg/analyzer/test/src/services/available_declarations_test.dart
index 0855c5d..40afa1c 100644
--- a/pkg/analyzer/test/src/services/available_declarations_test.dart
+++ b/pkg/analyzer/test/src/services/available_declarations_test.dart
@@ -202,7 +202,10 @@
}
test_getLibrary_exportViaRecursiveLink() async {
- resourceProvider.newLink('/home/test/lib/foo', '/home/test/lib');
+ resourceProvider.newLink(
+ convertPath('/home/test/lib/foo'),
+ convertPath('/home/test/lib'),
+ );
newFile('/home/test/lib/a.dart', content: r'''
export 'foo/a.dart';
diff --git a/pkg/dartdev/lib/dartdev.dart b/pkg/dartdev/lib/dartdev.dart
index 2ed2c66..777dd30 100644
--- a/pkg/dartdev/lib/dartdev.dart
+++ b/pkg/dartdev/lib/dartdev.dart
@@ -78,19 +78,6 @@
io.exit(0);
}
- // --launch-dds is provided by the VM if the VM service is to be enabled. In
- // that case, we need to launch DDS as well.
- final launchDdsArg = args.singleWhere(
- (element) => element.startsWith('--launch-dds'),
- orElse: () => null,
- );
- if (launchDdsArg != null) {
- RunCommand.launchDds = true;
- final ddsUrl = (launchDdsArg.split('=')[1]).split(':');
- RunCommand.ddsHost = ddsUrl[0];
- RunCommand.ddsPort = ddsUrl[1];
- }
-
String commandName;
try {
@@ -103,12 +90,6 @@
args = List.from(args)..remove('--disable-dartdev-analytics');
}
- // Run also can't be called with '--launch-dds', remove it if it's
- // contained in args.
- if (launchDdsArg != null) {
- args = List.from(args)..remove(launchDdsArg);
- }
-
// These flags have a format that can't be handled by package:args, so
// while they are valid flags we'll assume the VM has verified them by this
// point.
@@ -238,11 +219,6 @@
hide: true,
);
- // Another hidden flag used by the VM to indicate that DDS should be
- // launched. Should be removed for all commands other than `run`.
- argParser.addFlag('launch-dds',
- negatable: false, hide: true, help: 'Launch DDS.');
-
addCommand(AnalyzeCommand());
addCommand(CreateCommand(verbose: verbose));
addCommand(CompileCommand());
diff --git a/pkg/dartdev/lib/src/commands/run.dart b/pkg/dartdev/lib/src/commands/run.dart
index 9fa39e6..8a0a2ef 100644
--- a/pkg/dartdev/lib/src/commands/run.dart
+++ b/pkg/dartdev/lib/src/commands/run.dart
@@ -21,10 +21,6 @@
class RunCommand extends DartdevCommand<int> {
static const String cmdName = 'run';
- static bool launchDds = false;
- static String ddsHost;
- static String ddsPort;
-
// kErrorExitCode, as defined in runtime/bin/error_exit.h
static const errorExitCode = 255;
@@ -62,6 +58,7 @@
'with a set of common options useful for debugging.',
valueHelp: '[<port>[/<bind-address>]]',
)
+ ..addOption('launch-dds', hide: true, help: 'Launch DDS.')
..addSeparator(
'Options implied by --observe are currently:',
)
@@ -160,6 +157,22 @@
FutureOr<int> runImpl() async {
// The command line arguments after 'run'
var args = argResults.arguments.toList();
+ // --launch-dds is provided by the VM if the VM service is to be enabled. In
+ // that case, we need to launch DDS as well.
+ bool launchDds = false;
+ String ddsHost = '';
+ String ddsPort = '';
+
+ final launchDdsArg = args.singleWhere(
+ (element) => element.startsWith('--launch-dds'),
+ orElse: () => null,
+ );
+ if (launchDdsArg != null) {
+ launchDds = true;
+ final ddsUrl = (launchDdsArg.split('=')[1]).split(':');
+ ddsHost = ddsUrl[0];
+ ddsPort = ddsUrl[1];
+ }
var argsContainFile = false;
for (var arg in args) {
@@ -172,6 +185,9 @@
}
}
+ var disableServiceAuthCodes =
+ argResults['disable-service-auth-codes'] ?? false;
+
final cwd = Directory.current;
if (!argsContainFile && cwd.existsSync()) {
var foundImplicitFileToRun = false;
@@ -218,7 +234,8 @@
_DebuggingSession debugSession;
if (launchDds) {
debugSession = _DebuggingSession();
- if (!await debugSession.start()) {
+ if (!await debugSession.start(
+ ddsHost, ddsPort, disableServiceAuthCodes)) {
return errorExitCode;
}
}
@@ -251,7 +268,8 @@
}
class _DebuggingSession {
- Future<bool> start() async {
+ Future<bool> start(
+ String host, String port, bool disableServiceAuthCodes) async {
final serviceInfo = await Service.getInfo();
final ddsSnapshot = (dirname(sdk.dart).endsWith('bin'))
? sdk.ddsSnapshot
@@ -267,8 +285,9 @@
else
absolute(dirname(sdk.dart), 'gen', 'dds.dart.snapshot'),
serviceInfo.serverUri.toString(),
- RunCommand.ddsHost,
- RunCommand.ddsPort,
+ host,
+ port,
+ disableServiceAuthCodes.toString(),
],
mode: ProcessStartMode.detachedWithStdio);
final completer = Completer<void>();
diff --git a/pkg/dartdev/test/commands/run_test.dart b/pkg/dartdev/test/commands/run_test.dart
index 5c36e71..fc444ae 100644
--- a/pkg/dartdev/test/commands/run_test.dart
+++ b/pkg/dartdev/test/commands/run_test.dart
@@ -156,10 +156,29 @@
'--no-pause-isolates-on-unhandled-exceptions',
p.relativeFilePath,
]);
+ expect(
+ result.stdout,
+ matches(
+ r'Observatory listening on http://127.0.0.1:8181/[a-zA-Z0-9]+=/\n.*'),
+ );
+ expect(result.stderr, isEmpty);
+ expect(result.exitCode, 0);
+
+ // Again, with --disable-service-auth-codes.
+ result = p.runSync('run', [
+ '--observe',
+ '--pause-isolates-on-start',
+ // This should negate the above flag.
+ '--no-pause-isolates-on-start',
+ '--no-pause-isolates-on-exit',
+ '--no-pause-isolates-on-unhandled-exceptions',
+ '--disable-service-auth-codes',
+ p.relativeFilePath,
+ ]);
expect(
result.stdout,
- contains('Observatory listening on'),
+ contains('Observatory listening on http://127.0.0.1:8181/\n'),
);
expect(result.stderr, isEmpty);
expect(result.exitCode, 0);
diff --git a/pkg/dds/bin/dds.dart b/pkg/dds/bin/dds.dart
index ed683dd..3ac9a09 100644
--- a/pkg/dds/bin/dds.dart
+++ b/pkg/dds/bin/dds.dart
@@ -13,6 +13,7 @@
/// - VM service URI
/// - DDS bind address
/// - DDS port
+/// - Disable service authentication codes
Future<void> main(List<String> args) async {
if (args.isEmpty) return;
@@ -33,12 +34,14 @@
host: address.address,
port: int.parse(args[2]),
);
+ final disableServiceAuthCodes = args[3] == 'true';
try {
// TODO(bkonyi): add retry logic similar to that in vmservice_server.dart
// See https://github.com/dart-lang/sdk/issues/43192.
await DartDevelopmentService.startDartDevelopmentService(
remoteVmServiceUri,
serviceUri: serviceUri,
+ enableAuthCodes: !disableServiceAuthCodes,
);
stderr.write('DDS started');
} catch (e) {
diff --git a/pkg/front_end/lib/src/base/processed_options.dart b/pkg/front_end/lib/src/base/processed_options.dart
index 373eed1..ed2dc75 100644
--- a/pkg/front_end/lib/src/base/processed_options.dart
+++ b/pkg/front_end/lib/src/base/processed_options.dart
@@ -382,7 +382,6 @@
List<int> bytes = await loadSdkSummaryBytes();
if (bytes != null && bytes.isNotEmpty) {
_sdkSummaryComponent = loadComponent(bytes, nameRoot);
- _validateNullSafetyMode(_sdkSummaryComponent);
}
}
return _sdkSummaryComponent;
@@ -408,8 +407,7 @@
uris.map((uri) => _readAsBytes(fileSystem.entityForUri(uri))));
_additionalDillComponents = allBytes
.where((bytes) => bytes != null)
- .map((bytes) =>
- _validateNullSafetyMode(loadComponent(bytes, nameRoot)))
+ .map((bytes) => loadComponent(bytes, nameRoot))
.toList();
}
return _additionalDillComponents;
diff --git a/pkg/nnbd_migration/lib/nnbd_migration.dart b/pkg/nnbd_migration/lib/nnbd_migration.dart
index 5be23ba..787b235 100644
--- a/pkg/nnbd_migration/lib/nnbd_migration.dart
+++ b/pkg/nnbd_migration/lib/nnbd_migration.dart
@@ -18,29 +18,29 @@
/// Description of fixes that might be performed by nullability migration.
class NullabilityFixDescription {
/// A variable declaration needs to be marked as "late".
- static const addLate = const NullabilityFixDescription._(
+ static const addLate = NullabilityFixDescription._(
appliedMessage: 'Added a late keyword', kind: NullabilityFixKind.addLate);
/// A variable declaration needs to be marked as "late" due to the presence of
/// a `/*late*/` hint.
- static const addLateDueToHint = const NullabilityFixDescription._(
+ static const addLateDueToHint = NullabilityFixDescription._(
appliedMessage: 'Added a late keyword, due to a hint',
kind: NullabilityFixKind.addLateDueToHint);
/// A variable declaration needs to be marked as "late" due to being certainly
/// assigned in test setup.
- static const addLateDueToTestSetup = const NullabilityFixDescription._(
+ static const addLateDueToTestSetup = NullabilityFixDescription._(
appliedMessage: 'Added a late keyword, due to assignment in `setUp`',
kind: NullabilityFixKind.addLateDueToTestSetup);
/// An expression's value needs to be null-checked.
- static const checkExpression = const NullabilityFixDescription._(
+ static const checkExpression = NullabilityFixDescription._(
appliedMessage: 'Added a non-null assertion to nullable expression',
kind: NullabilityFixKind.checkExpression,
);
/// An expression's value will be null-checked due to a hint.
- static const checkExpressionDueToHint = const NullabilityFixDescription._(
+ static const checkExpressionDueToHint = NullabilityFixDescription._(
appliedMessage: 'Accepted a null check hint',
kind: NullabilityFixKind.checkExpressionDueToHint,
);
@@ -48,47 +48,47 @@
/// A compound assignment's combiner operator returns a type that isn't
/// assignable to the LHS of the assignment.
static const compoundAssignmentHasBadCombinedType =
- const NullabilityFixDescription._(
+ NullabilityFixDescription._(
appliedMessage: 'Compound assignment has bad combined type',
kind: NullabilityFixKind.compoundAssignmentHasBadCombinedType,
);
/// A compound assignment's LHS has a nullable type.
static const compoundAssignmentHasNullableSource =
- const NullabilityFixDescription._(
+ NullabilityFixDescription._(
appliedMessage: 'Compound assignment has nullable source',
kind: NullabilityFixKind.compoundAssignmentHasNullableSource,
);
/// Informative message: a condition of an if-test or conditional expression
/// will always evaluate to `false` in strong checking mode.
- static const conditionFalseInStrongMode = const NullabilityFixDescription._(
+ static const conditionFalseInStrongMode = NullabilityFixDescription._(
appliedMessage: 'Condition will always be false in strong checking mode',
kind: NullabilityFixKind.conditionFalseInStrongMode);
/// Informative message: a condition of an if-test or conditional expression
/// will always evaluate to `true` in strong checking mode.
- static const conditionTrueInStrongMode = const NullabilityFixDescription._(
+ static const conditionTrueInStrongMode = NullabilityFixDescription._(
appliedMessage: 'Condition will always be true in strong checking mode',
kind: NullabilityFixKind.conditionTrueInStrongMode);
/// An if-test or conditional expression needs to have its condition
/// discarded.
- static const discardCondition = const NullabilityFixDescription._(
+ static const discardCondition = NullabilityFixDescription._(
appliedMessage: 'Discarded a condition which is always true',
kind: NullabilityFixKind.removeDeadCode,
);
/// An if-test or conditional expression needs to have its condition and
/// "else" branch discarded.
- static const discardElse = const NullabilityFixDescription._(
+ static const discardElse = NullabilityFixDescription._(
appliedMessage: 'Discarded an unreachable conditional else branch',
kind: NullabilityFixKind.removeDeadCode,
);
/// An if-test or conditional expression needs to have its condition and
/// "then" branch discarded.
- static const discardThen = const NullabilityFixDescription._(
+ static const discardThen = NullabilityFixDescription._(
appliedMessage:
'Discarded a condition which is always false, and the "then" branch '
'that follows',
@@ -96,12 +96,12 @@
);
/// An if-test needs to be discarded completely.
- static const discardIf = const NullabilityFixDescription._(
+ static const discardIf = NullabilityFixDescription._(
appliedMessage: 'Discarded an if-test with no effect',
kind: NullabilityFixKind.removeDeadCode,
);
- static const downcastExpression = const NullabilityFixDescription._(
+ static const downcastExpression = NullabilityFixDescription._(
appliedMessage: 'Added a downcast to an expression',
kind: NullabilityFixKind.downcastExpression,
);
@@ -109,7 +109,7 @@
/// Informative message: a null-aware access won't be necessary in strong
/// checking mode.
static const nullAwarenessUnnecessaryInStrongMode =
- const NullabilityFixDescription._(
+ NullabilityFixDescription._(
appliedMessage:
'Null-aware access will be unnecessary in strong checking mode',
kind: NullabilityFixKind.nullAwarenessUnnecessaryInStrongMode);
@@ -117,38 +117,38 @@
/// Informative message: a null-aware assignment won't be necessary in strong
/// checking mode.
static const nullAwareAssignmentUnnecessaryInStrongMode =
- const NullabilityFixDescription._(
+ NullabilityFixDescription._(
appliedMessage:
'Null-aware assignment will be unnecessary in strong checking mode',
kind: NullabilityFixKind.nullAwareAssignmentUnnecessaryInStrongMode);
- static const otherCastExpression = const NullabilityFixDescription._(
+ static const otherCastExpression = NullabilityFixDescription._(
appliedMessage: 'Added a cast to an expression (non-downcast)',
kind: NullabilityFixKind.otherCastExpression,
);
/// An unnecessary downcast has been discarded.
- static const removeLanguageVersionComment = const NullabilityFixDescription._(
+ static const removeLanguageVersionComment = NullabilityFixDescription._(
appliedMessage: 'Removed language version comment so that NNBD features '
'will be allowed in this file',
kind: NullabilityFixKind.removeLanguageVersionComment,
);
/// An unnecessary downcast has been discarded.
- static const removeAs = const NullabilityFixDescription._(
+ static const removeAs = NullabilityFixDescription._(
appliedMessage: 'Discarded a downcast that is now unnecessary',
kind: NullabilityFixKind.removeAs,
);
/// A null-aware operator needs to be changed into its non-null-aware
/// equivalent.
- static const removeNullAwareness = const NullabilityFixDescription._(
+ static const removeNullAwareness = NullabilityFixDescription._(
appliedMessage:
'Changed a null-aware access into an ordinary access, because the target cannot be null',
kind: NullabilityFixKind.removeDeadCode);
/// A null-aware assignment was removed because its LHS is non-nullable.
- static const removeNullAwareAssignment = const NullabilityFixDescription._(
+ static const removeNullAwareAssignment = NullabilityFixDescription._(
appliedMessage:
'Removed a null-aware assignment, because the target cannot be null',
kind: NullabilityFixKind.removeDeadCode);
diff --git a/runtime/bin/main_options.cc b/runtime/bin/main_options.cc
index f1d8649..7c54268 100644
--- a/runtime/bin/main_options.cc
+++ b/runtime/bin/main_options.cc
@@ -485,6 +485,7 @@
// The arguments to the VM are at positions 1 through i-1 in argv.
Platform::SetExecutableArguments(i, argv);
+ bool implicitly_use_dart_dev = false;
bool run_script = false;
int script_or_cmd_index = -1;
@@ -496,7 +497,6 @@
// to find the DartDev snapshot so we can forward the command and its
// arguments.
bool is_potential_file_path = !DartDevIsolate::ShouldParseCommand(argv[i]);
- bool implicitly_use_dart_dev = false;
#else
bool is_potential_file_path = true;
#endif // !defined(DART_PRECOMPILED_RUNTIME)
@@ -511,13 +511,14 @@
else { // NOLINT
DartDevIsolate::set_should_run_dart_dev(true);
}
- // Handle the special case where the user is running a Dart program without
- // using a DartDev command and wants to use the VM service. Here we'll run
- // the program using DartDev as it's used to spawn a DDS instance
- if (!Options::disable_dart_dev() && is_potential_file_path &&
- enable_vm_service_) {
- implicitly_use_dart_dev = true;
- dart_options->AddArgument("run");
+ if (!Options::disable_dart_dev() && enable_vm_service_) {
+ // Handle the special case where the user is running a Dart program
+ // without using a DartDev command and wants to use the VM service. Here
+ // we'll run the program using DartDev as it's used to spawn a DDS
+ // instance.
+ if (is_potential_file_path) {
+ implicitly_use_dart_dev = true;
+ }
}
#endif // !defined(DART_PRECOMPILED_RUNTIME)
}
@@ -591,26 +592,58 @@
}
#endif // !defined(DART_PRECOMPILED_RUNTIME)
+ // If running with dartdev, attempt to parse VM flags which are part of the
+ // dartdev command (e.g., --enable-vm-service, --observe, etc).
+ if (!run_script) {
+ int tmp_i = i;
+ while (tmp_i < argc) {
+ OptionProcessor::TryProcess(argv[tmp_i], vm_options);
+ tmp_i++;
+ }
+ }
+ bool first_option = true;
// Parse out options to be passed to dart main.
while (i < argc) {
- if (!run_script) {
- OptionProcessor::TryProcess(argv[i], vm_options);
+ if (implicitly_use_dart_dev && first_option) {
+ // Special case where user enables VM service without using a dartdev
+ // run command. If 'run' is provided, it will be the first argument
+ // processed in this loop.
+ dart_options->AddArgument("run");
+ } else {
+ dart_options->AddArgument(argv[i]);
+ i++;
}
- dart_options->AddArgument(argv[i]);
- i++;
+ // Add DDS specific flags immediately after the dartdev command.
+ if (first_option) {
+ // DDS is only enabled for the run command. Make sure we don't pass DDS
+ // specific flags along with other commands, otherwise argument parsing
+ // will fail unexpectedly.
+ bool run_command = implicitly_use_dart_dev;
+ if (!run_command && strcmp(argv[i - 1], "run") == 0) {
+ run_command = true;
+ }
+ if (!Options::disable_dart_dev() && enable_vm_service_ && run_command) {
+ const char* dds_format_str = "--launch-dds=%s:%d";
+ size_t size =
+ snprintf(nullptr, 0, dds_format_str, vm_service_server_ip(),
+ vm_service_server_port());
+ // Make room for '\0'.
+ ++size;
+ char* dds_uri = new char[size];
+ snprintf(dds_uri, size, dds_format_str, vm_service_server_ip(),
+ vm_service_server_port());
+ dart_options->AddArgument(dds_uri);
+
+ // Only add --disable-service-auth-codes if dartdev is being run
+ // implicitly. Otherwise it will already be forwarded.
+ if (implicitly_use_dart_dev && Options::vm_service_auth_disabled()) {
+ dart_options->AddArgument("--disable-service-auth-codes");
+ }
+ }
+ first_option = false;
+ }
}
- if (!Options::disable_dart_dev() && enable_vm_service_) {
- const char* dds_format_str = "--launch-dds=%s:%d";
- size_t size = snprintf(nullptr, 0, dds_format_str, vm_service_server_ip(),
- vm_service_server_port());
- // Make room for '\0'.
- ++size;
- char* dds_uri = new char[size];
- snprintf(dds_uri, size, dds_format_str, vm_service_server_ip(),
- vm_service_server_port());
- dart_options->AddArgument(dds_uri);
- }
// Verify consistency of arguments.
diff --git a/runtime/tests/vm/vm.status b/runtime/tests/vm/vm.status
index 3100658..42a3df8 100644
--- a/runtime/tests/vm/vm.status
+++ b/runtime/tests/vm/vm.status
@@ -369,6 +369,12 @@
dart/thread_priority_linux_test: SkipByDesign
dart_2/thread_priority_linux_test: SkipByDesign
+[ $builder_tag == bytecode_interpreter || $builder_tag == bytecode_interpreter_nnbd || $builder_tag == bytecode_mixed || $builder_tag == bytecode_mixed_nnbd ]
+cc/StreamingFlowGraphBuilder_ConcatStringLits: SkipByDesign # Optimisation isn't run for bytecode functions.
+cc/StreamingFlowGraphBuilder_ConstFoldStringConcats: SkipByDesign # Optimisation isn't run for bytecode functions.
+cc/StreamingFlowGraphBuilder_DropEmptyStringInterp: SkipByDesign # Optimisation isn't run for bytecode functions.
+cc/StreamingFlowGraphBuilder_FlattenNestedStringInterp: SkipByDesign # Optimisation isn't run for bytecode functions.
+
[ $builder_tag == bytecode_interpreter || $builder_tag == bytecode_interpreter_nnbd || $hot_reload || $hot_reload_rollback || $compiler != dartk && $compiler != dartkb && $compiler != dartkp ]
dart/entrypoints/*: SkipByDesign # These tests are for compiler optimizations and very sensitive to when functions are optimized, so they are disabled on hotreload and optcounter bots.
dart_2/entrypoints/*: SkipByDesign # These tests are for compiler optimizations and very sensitive to when functions are optimized, so they are disabled on hotreload and optcounter bots.
diff --git a/sdk/lib/_http/http_impl.dart b/sdk/lib/_http/http_impl.dart
index eb0dee4..4731868 100644
--- a/sdk/lib/_http/http_impl.dart
+++ b/sdk/lib/_http/http_impl.dart
@@ -252,7 +252,9 @@
var proto = headers['x-forwarded-proto'];
var scheme = proto != null
? proto.first
- : _httpConnection._socket is SecureSocket ? "https" : "http";
+ : _httpConnection._socket is SecureSocket
+ ? "https"
+ : "http";
var hostList = headers['x-forwarded-host'];
String host;
if (hostList != null) {
@@ -1120,6 +1122,7 @@
final _HttpClient _httpClient;
final _HttpClientConnection _httpClientConnection;
final TimelineTask? _timeline;
+ final TimelineTask? _responseTimeline;
final Completer<HttpClientResponse> _responseCompleter =
new Completer<HttpClientResponse>();
@@ -1137,10 +1140,17 @@
bool _aborted = false;
- _HttpClientRequest(_HttpOutgoing outgoing, Uri uri, this.method, this._proxy,
- this._httpClient, this._httpClientConnection, this._timeline)
+ _HttpClientRequest(
+ _HttpOutgoing outgoing,
+ Uri uri,
+ this.method,
+ this._proxy,
+ this._httpClient,
+ this._httpClientConnection,
+ this._timeline,
+ this._responseTimeline)
: uri = uri,
- super(uri, "1.1", outgoing, _timeline) {
+ super(uri, "1.1", outgoing, _responseTimeline) {
_timeline?.instant('Request initiated');
// GET and HEAD have 'content-length: 0' by default.
if (method == "GET" || method == "HEAD") {
@@ -1194,7 +1204,8 @@
});
// Start the timeline for response.
- _timeline?.start('HTTP CLIENT response of ${method.toUpperCase()}',
+ _responseTimeline?.start(
+ 'HTTP CLIENT response of ${method.toUpperCase()}',
arguments: {
'requestUri': uri.toString(),
'statusCode': response.statusCode,
@@ -1235,7 +1246,7 @@
return;
}
final response =
- _HttpClientResponse(incoming, this, _httpClient, _timeline);
+ _HttpClientResponse(incoming, this, _httpClient, _responseTimeline);
Future<HttpClientResponse> future;
if (followRedirects && response.isRedirect) {
if (response.redirects.length < maxRedirects) {
@@ -1859,9 +1870,16 @@
_ProxyCredentials? proxyCreds; // Credentials used to authorize proxy.
_SiteCredentials? creds; // Credentials used to authorize this request.
var outgoing = new _HttpOutgoing(_socket);
+
+ final responseTimeline = timeline == null
+ ? null
+ : TimelineTask(
+ parent: timeline,
+ filterKey: 'HTTP/client',
+ );
// Create new request object, wrapping the outgoing connection.
- var request = new _HttpClientRequest(
- outgoing, uri, method, proxy, _httpClient, this, timeline);
+ var request = new _HttpClientRequest(outgoing, uri, method, proxy,
+ _httpClient, this, timeline, responseTimeline);
// For the Host header an IPv6 address must be enclosed in []'s.
var host = uri.host;
if (host.contains(':')) host = "[$host]";
diff --git a/sdk/lib/_internal/js_runtime/lib/regexp_helper.dart b/sdk/lib/_internal/js_runtime/lib/regexp_helper.dart
index 4f182d0..16ab9b0 100644
--- a/sdk/lib/_internal/js_runtime/lib/regexp_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/regexp_helper.dart
@@ -249,7 +249,7 @@
_AllMatchesIterator(this._regExp, this._string, this._nextIndex);
- RegExpMatch get current => _current!;
+ RegExpMatch get current => _current as RegExpMatch;
static bool _isLeadSurrogate(int c) {
return c >= 0xd800 && c <= 0xdbff;
diff --git a/sdk/lib/_internal/vm/lib/regexp_patch.dart b/sdk/lib/_internal/vm/lib/regexp_patch.dart
index 7a57583..153080b 100644
--- a/sdk/lib/_internal/vm/lib/regexp_patch.dart
+++ b/sdk/lib/_internal/vm/lib/regexp_patch.dart
@@ -376,7 +376,7 @@
_AllMatchesIterator(this._re, this._str, this._nextIndex);
- RegExpMatch get current => _current!;
+ RegExpMatch get current => _current as RegExpMatch;
static bool _isLeadSurrogate(int c) {
return c >= 0xd800 && c <= 0xdbff;
diff --git a/sdk/lib/ffi/struct.dart b/sdk/lib/ffi/struct.dart
index c6605d8..f4cb315 100644
--- a/sdk/lib/ffi/struct.dart
+++ b/sdk/lib/ffi/struct.dart
@@ -29,7 +29,7 @@
Struct._fromPointer(this._addressOf);
}
-/// Extension on [Struct] specialized for it's subtypes.
+/// Extension on [Struct] specialized for its subtypes.
extension StructAddressOf<T extends Struct> on T {
/// Returns the address backing the reference.
Pointer<T> get addressOf => _addressOf as Pointer<T>;
diff --git a/tests/corelib/reg_exp_all_matches_test.dart b/tests/corelib/reg_exp_all_matches_test.dart
index 59996ff..54fbf10 100644
--- a/tests/corelib/reg_exp_all_matches_test.dart
+++ b/tests/corelib/reg_exp_all_matches_test.dart
@@ -10,6 +10,11 @@
static testIterator() {
var matches = new RegExp("foo").allMatches("foo foo");
Iterator it = matches.iterator;
+ if (isStrongMode) {
+ Expect.throws(() => it.current);
+ } else {
+ Expect.isNull(it.current);
+ }
Expect.isTrue(it.moveNext());
Expect.equals('foo', it.current.group(0));
Expect.isTrue(it.moveNext());
diff --git a/tests/corelib_2/reg_exp_all_matches_test.dart b/tests/corelib_2/reg_exp_all_matches_test.dart
index 72a2344..3cb966d 100644
--- a/tests/corelib_2/reg_exp_all_matches_test.dart
+++ b/tests/corelib_2/reg_exp_all_matches_test.dart
@@ -10,6 +10,7 @@
static testIterator() {
var matches = new RegExp("foo").allMatches("foo foo");
Iterator it = matches.iterator;
+ Expect.isNull(it.current);
Expect.isTrue(it.moveNext());
Expect.equals('foo', it.current.group(0));
Expect.isTrue(it.moveNext());
diff --git a/tools/VERSION b/tools/VERSION
index 6868e51..c246888 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 10
PATCH 0
-PRERELEASE 145
+PRERELEASE 146
PRERELEASE_PATCH 0
\ No newline at end of file
diff --git a/tools/bots/test_matrix.json b/tools/bots/test_matrix.json
index 9004af0..cb9855d 100644
--- a/tools/bots/test_matrix.json
+++ b/tools/bots/test_matrix.json
@@ -1184,7 +1184,7 @@
"co19"
],
"fileset": "front-end",
- "shards": 1
+ "shards": 2
},
{
"name": "strong co19 tests",
@@ -1193,7 +1193,7 @@
"co19"
],
"fileset": "front-end",
- "shards": 1
+ "shards": 2
},
{
"name": "weak sdk tests",