Skip to content

Commit

Permalink
Version 2.18.0-171.0.dev
Browse files Browse the repository at this point in the history
Merge commit 'de8f84f62d58ab4d124a9706b34ae81de7b1ae34' into 'dev'
  • Loading branch information
Dart CI committed Jun 8, 2022
2 parents 6a7e6de + de8f84f commit 68fd701
Show file tree
Hide file tree
Showing 242 changed files with 24,041 additions and 16,586 deletions.
36 changes: 23 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ them, you must set the lower bound on the SDK constraint for your package to

#### `dart:io`

- **Breaking Change** [#34218](https://github.com/dart-lang/sdk/issues/34218):
Constants in `dart:io`'s networking APIs following the `SCREAMING_CAPS`
convention have been removed (they were previously deprecated). Please use
the corresponding `lowerCamelCase` constants instead.

- **Breaking Change** [#45630][]: The Dart VM no longer automatically restores
the initial terminal settings upon exit. Programs that change the `Stdin`
settings `lineMode` and `echoMode` are now responsible for restoring the
Expand Down Expand Up @@ -113,28 +118,33 @@ them, you must set the lower bound on the SDK constraint for your package to

#### Linter

Updated the Linter to `1.24.0`, which includes changes that
Updated the Linter to `1.25.0`, which includes changes that

- fixes `prefer_final_parameters` to support super parameters.
- adds new lint: `unnecessary_to_list_in_spreads`.
- fixes `unawaited_futures` to handle string interpolated
- add new lint: `discarded_futures`.
- improve message and highlight range for `no_duplicate_case_values`
- improve performance for `lines_longer_than_80_chars`,
`prefer_const_constructors_in_immutables`, and
`prefer_initializing_formals`.
- fix `prefer_final_parameters` to support super parameters.
- add new lint: `unnecessary_to_list_in_spreads`.
- fix `unawaited_futures` to handle string interpolated
futures.
- updates `use_colored_box` to not flag nullable colors,
- adds new lint:
- update `use_colored_box` to not flag nullable colors,
- add new lint:
`unnecessary_null_aware_operator_on_extension_on_nullable`.
- fixes `no_leading_underscores_for_local_identifiers`
- fix `no_leading_underscores_for_local_identifiers`
to lint local function declarations.
- fixes `avoid_init_to_null` to correctly handle super
- fix `avoid_init_to_null` to correctly handle super
initializing defaults that are non-null.
- updates `no_leading_underscores_for_local_identifiers`
- update `no_leading_underscores_for_local_identifiers`
to allow identifiers with just underscores.
- fixes `flutter_style_todos` to support usernames that
- fix `flutter_style_todos` to support usernames that
start with a digit.
- updates `require_trailing_commas` to handle functions
- update `require_trailing_commas` to handle functions
in asserts and multi-line strings.
- updates `unsafe_html` to allow assignments to
- update `unsafe_html` to allow assignments to
`img.src`.
- fixes `unnecessary_null_checks` to properly handle map
- fix `unnecessary_null_checks` to properly handle map
literal entries.

#### Pub
Expand Down
4 changes: 2 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ vars = {
# For more details, see https://github.com/dart-lang/sdk/issues/30164.
"dart_style_rev": "d7b73536a8079331c888b7da539b80e6825270ea",

"dartdoc_rev": "8549817bb1b59808108e83ef0e513157cb572d2a",
"dartdoc_rev": "f5bcc4bd46f4ce956b6c27ebaf741f6e90d7fca9",
"devtools_rev": "51ac983d2db7eb19b3ce5956cb70b769d74fe784",
"ffi_rev": "0c8364a728cfe4e4ba859c53b99d56b3dbe3add4",
"file_rev": "0132eeedea2933513bf230513a766a8baeab0c4f",
Expand All @@ -120,7 +120,7 @@ vars = {
"intl_rev": "9145f308f1458f37630a1ffce3b7d3b471ebbc56",
"jinja2_rev": "2222b31554f03e62600cd7e383376a7c187967a1",
"json_rpc_2_rev": "2de9a1f9821807fa2c85fd48e2f70b9cbcddcb67",
"linter_rev": "a8529c6692922b45bc287543b355c90d7b1286d3", # 1.24.0
"linter_rev": "1ddc70948d94f2449fec69a95e3ceb7b6b6c8348", # 1.25.0
"lints_rev": "8294e5648ab49474541527e2911e72e4c5aefe55",
"logging_rev": "f6979e3bc3b6e1847a08335b7eb6304e18986195",
"markdown_rev": "e3f4bd28c9e61b522f75f291d4d6cfcfeccd83ee", # 5.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import '../js_interop.dart'

/// Replaces:
/// 1) Factory constructors in classes with `@staticInterop` annotations with
/// calls to `js_util_wasm.callConstructorVarArgs`.
/// calls to `js_util.callConstructor`.
/// 2) External methods in `@staticInterop` class extensions to their
/// corresponding `js_util_wasm` calls.
/// corresponding `js_util` calls.
/// TODO(joshualitt): In the long term we'd like to have the same
/// `JsUtilOptimizer` for all web backends. This is to ensure uniform semantics
/// across all web backends. Some known challenges remain, and there may be
Expand All @@ -45,21 +45,18 @@ import '../js_interop.dart'
class JsUtilWasmOptimizer extends Transformer {
final Procedure _callMethodTarget;
final Procedure _callConstructorTarget;
final Procedure _globalThisTarget;
final Procedure _getPropertyTarget;
final Procedure _setPropertyTarget;
final Procedure _jsifyTarget;
final Procedure _jsifyRawTarget;
final Procedure _dartifyTarget;
final Procedure _newObjectTarget;
final Procedure _wrapDartCallbackTarget;
final Procedure _allowInteropTarget;
final Class _jsValueClass;
final Class _wasmAnyRefClass;
final Class _objectClass;
final Class _pragmaClass;
final Field _pragmaName;
final Field _pragmaOptions;
final Member _globalThisMember;
int _callbackTrampolineN = 1;

final CoreTypes _coreTypes;
Expand All @@ -68,30 +65,24 @@ class JsUtilWasmOptimizer extends Transformer {
final Set<Class> _transformedClasses = {};

JsUtilWasmOptimizer(this._coreTypes, ClassHierarchy hierarchy)
: _callMethodTarget = _coreTypes.index
.getTopLevelProcedure('dart:js_util_wasm', 'callMethodVarArgs'),
_globalThisTarget = _coreTypes.index
.getTopLevelProcedure('dart:js_util_wasm', 'globalThis'),
_callConstructorTarget = _coreTypes.index.getTopLevelProcedure(
'dart:js_util_wasm', 'callConstructorVarArgs'),
: _callMethodTarget =
_coreTypes.index.getTopLevelProcedure('dart:js_util', 'callMethod'),
_globalThisMember = _coreTypes.index
.getTopLevelMember('dart:js_util', 'get:globalThis'),
_callConstructorTarget = _coreTypes.index
.getTopLevelProcedure('dart:js_util', 'callConstructor'),
_getPropertyTarget = _coreTypes.index
.getTopLevelProcedure('dart:js_util_wasm', 'getProperty'),
.getTopLevelProcedure('dart:js_util', 'getProperty'),
_setPropertyTarget = _coreTypes.index
.getTopLevelProcedure('dart:js_util_wasm', 'setProperty'),
_jsifyTarget =
_coreTypes.index.getTopLevelProcedure('dart:js_util_wasm', 'jsify'),
.getTopLevelProcedure('dart:js_util', 'setProperty'),
_jsifyRawTarget = _coreTypes.index
.getTopLevelProcedure('dart:js_util_wasm', 'jsifyRaw'),
_dartifyTarget = _coreTypes.index
.getTopLevelProcedure('dart:js_util_wasm', 'dartify'),
.getTopLevelProcedure('dart:_js_helper', 'jsifyRaw'),
_wrapDartCallbackTarget = _coreTypes.index
.getTopLevelProcedure('dart:js_util_wasm', '_wrapDartCallback'),
_newObjectTarget = _coreTypes.index
.getTopLevelProcedure('dart:js_util_wasm', 'newObject'),
_newObjectTarget =
_coreTypes.index.getTopLevelProcedure('dart:js_util', 'newObject'),
_allowInteropTarget = _coreTypes.index
.getTopLevelProcedure('dart:js_util_wasm', 'allowInterop'),
_jsValueClass =
_coreTypes.index.getClass('dart:js_util_wasm', 'JSValue'),
_wasmAnyRefClass = _coreTypes.index.getClass('dart:wasm', 'WasmAnyRef'),
_objectClass = _coreTypes.objectClass,
_pragmaClass = _coreTypes.pragmaClass,
Expand Down Expand Up @@ -120,6 +111,7 @@ class JsUtilWasmOptimizer extends Transformer {

@override
StaticInvocation visitStaticInvocation(StaticInvocation node) {
node = super.visitStaticInvocation(node) as StaticInvocation;
if (node.target == _allowInteropTarget) {
Expression argument = node.arguments.positional.single;
DartType functionType = argument.getStaticType(_staticTypeContext);
Expand Down Expand Up @@ -208,14 +200,11 @@ class JsUtilWasmOptimizer extends Transformer {
return _extensionMemberIndex!;
}

DartType get _nullableJSValueType =>
_jsValueClass.getThisType(_coreTypes, Nullability.nullable);
DartType get _nullableObjectType =>
_coreTypes.objectRawType(Nullability.nullable);

DartType get _nonNullableJSValueType =>
_jsValueClass.getThisType(_coreTypes, Nullability.nonNullable);

Expression _dartify(Expression expression) =>
StaticInvocation(_dartifyTarget, Arguments([expression]));
DartType get _nonNullableObjectType =>
_coreTypes.objectRawType(Nullability.nonNullable);

/// Creates a callback trampoline for the given [function]. This callback
/// trampoline expects a Dart callback as its first argument, followed by all
Expand Down Expand Up @@ -298,17 +287,7 @@ class JsUtilWasmOptimizer extends Transformer {
Arguments([argument, StringLiteral(callbackTrampolineName)]));
}

Expression _jsifyVariable(Procedure node, VariableDeclaration variable) {
if (variable.type is FunctionType) {
return _allowInterop(
node, variable.type as FunctionType, VariableGet(variable));
} else {
return StaticInvocation(_jsifyTarget, Arguments([VariableGet(variable)]));
}
}

StaticInvocation get _globalThis =>
StaticInvocation(_globalThisTarget, Arguments([]));
StaticGet get _globalThis => StaticGet(_globalThisMember);

/// Takes a list of [selectors] and returns an object off of
/// `globalThis`. We could optimize this with a custom method built with
Expand All @@ -329,8 +308,9 @@ class JsUtilWasmOptimizer extends Transformer {
Block _getExternalAnonymousConstructorBody(Procedure node) {
List<Statement> body = [];
final object = VariableDeclaration('|anonymousObject',
initializer: StaticInvocation(_newObjectTarget, Arguments([])),
type: _nonNullableJSValueType);
initializer: StaticInvocation(
_newObjectTarget, Arguments([], types: [node.function.returnType])),
type: _nonNullableObjectType);
body.add(object);
for (VariableDeclaration variable in node.function.namedParameters) {
body.add(ExpressionStatement(
Expand All @@ -342,21 +322,22 @@ class JsUtilWasmOptimizer extends Transformer {

/// Returns a new function body for the given [node] external method.
///
/// The new function body will call `js_util_wasm.callConstructorVarArgs`
/// The new function body will call `js_util.callConstructor`
/// for the given external method.
ReturnStatement _getExternalCallConstructorBody(
Procedure node, String constructorName) {
var function = node.function;
var callConstructorInvocation = StaticInvocation(
_callConstructorTarget,
Arguments([
_globalThis,
StringLiteral(constructorName),
_getProperty(node, _globalThis, constructorName),
ListLiteral(
function.positionalParameters
.map((arg) => _jsifyVariable(node, arg))
.map<Expression>((value) => VariableGet(value))
.toList(),
typeArgument: _nonNullableJSValueType)
typeArgument: _nullableObjectType)
], types: [
node.function.returnType
]))
..fileOffset = node.fileOffset;
return ReturnStatement(callConstructorInvocation);
Expand All @@ -365,17 +346,19 @@ class JsUtilWasmOptimizer extends Transformer {
/// Returns a new [Expression] for the given [node] external getter.
///
/// The new [Expression] is equivalent to:
/// `js_util_wasm.getProperty([object], [getterName])`.
/// `js_util.getProperty([object], [getterName])`.
Expression _getProperty(
Procedure node, Expression object, String getterName) =>
StaticInvocation(
_getPropertyTarget, Arguments([object, StringLiteral(getterName)]))
_getPropertyTarget,
Arguments([object, StringLiteral(getterName)],
types: [node.function.returnType]))
..fileOffset = node.fileOffset;

/// Returns a new function body for the given [node] external getter.
ReturnStatement _getExternalGetterBody(
Procedure node, Expression object, String getterName) =>
ReturnStatement(_dartify(_getProperty(node, object, getterName)));
ReturnStatement(_getProperty(node, object, getterName));

ReturnStatement _getExternalExtensionGetterBody(Procedure node) =>
_getExternalGetterBody(
Expand All @@ -390,19 +373,19 @@ class JsUtilWasmOptimizer extends Transformer {
/// Returns a new [Expression] for the given [node] external setter.
///
/// The new [Expression] is equivalent to:
/// `js_util_wasm.setProperty([object], [setterName], [value])`.
/// `js_util.setProperty([object], [setterName], [value])`.
Expression _setProperty(Procedure node, Expression object, String setterName,
VariableDeclaration value) =>
StaticInvocation(
_setPropertyTarget,
Arguments(
[object, StringLiteral(setterName), _jsifyVariable(node, value)]))
Arguments([object, StringLiteral(setterName), VariableGet(value)],
types: [node.function.returnType]))
..fileOffset = node.fileOffset;

/// Returns a new function body for the given [node] external setter.
ReturnStatement _getExternalSetterBody(Procedure node, Expression object,
String setterName, VariableDeclaration value) =>
ReturnStatement(_dartify(_setProperty(node, object, setterName, value)));
ReturnStatement(_setProperty(node, object, setterName, value));

ReturnStatement _getExternalExtensionSetterBody(Procedure node) {
final parameters = node.function.positionalParameters;
Expand All @@ -419,18 +402,20 @@ class JsUtilWasmOptimizer extends Transformer {
/// Returns a new function body for the given [node] external method.
///
/// The new function body is equivalent to:
/// `js_util_wasm.callMethodVarArgs([object], [methodName], [values])`.
/// `js_util.callMethod([object], [methodName], [values])`.
ReturnStatement _getExternalMethodBody(Procedure node, Expression object,
String methodName, List<VariableDeclaration> values) {
final callMethodInvocation = _dartify(StaticInvocation(
final callMethodInvocation = StaticInvocation(
_callMethodTarget,
Arguments([
object,
StringLiteral(methodName),
ListLiteral(
values.map((value) => _jsifyVariable(node, value)).toList(),
typeArgument: _nullableJSValueType)
])))
values.map<Expression>((value) => VariableGet(value)).toList(),
typeArgument: _nullableObjectType)
], types: [
node.function.returnType
]))
..fileOffset = node.fileOffset;
return ReturnStatement(callMethodInvocation);
}
Expand Down
Loading

0 comments on commit 68fd701

Please sign in to comment.