Skip to content

Commit

Permalink
Version 3.6.0-85.0.dev
Browse files Browse the repository at this point in the history
Merge 6574ac9 into dev
  • Loading branch information
Dart CI committed Jul 26, 2024
2 parents da2dbd8 + 6574ac9 commit 1b29ac3
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 44 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ vars = {
# and land the review.
#
# For more details, see https://github.com/dart-lang/sdk/issues/30164.
"dart_style_rev": "a6ad7693555a9add6f98ad6fd94de80d35c89415", # disable tools/rev_sdk_deps.dart
"dart_style_rev": "f7bd4c42ad6015143f08931540631448048f692d", # disable tools/rev_sdk_deps.dart
"dartdoc_rev": "5230f8fd10d51ef379993928ae5813bda103b78d",
"ecosystem_rev": "2635536f8fbb13ca8349e5e461a1b45320bc01ea",
"file_rev": "855831c242a17c2dee163828d52710d9043c7c8d",
Expand Down
51 changes: 24 additions & 27 deletions pkg/dev_compiler/lib/src/kernel/compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2321,9 +2321,8 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
var name = _propertyName(param.name!);
var paramType = superMethodType.namedParameters
.firstWhere((n) => n.name == param.name);
body.add(js.statement('if (# in #) #;', [
name,
_namedArgumentTemp,
body.add(js.statement('if (#) #;', [
_namedArgumentProbe(name),
_emitCast(
js_ast.PropertyAccess(_namedArgumentTemp, name), paramType.type)
]));
Expand Down Expand Up @@ -3823,27 +3822,17 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
// Parameters will be passed using their real names, not the (possibly
// renamed) local variable.
var jsParam = _emitVariableDef(p);
var paramName = js.string(p.name!, "'");
var paramName = _propertyName(p.name!);
var defaultValue = _defaultParamValue(p);
if (defaultValue != null) {
// TODO(ochafik): Fix `'prop' in obj` to please Closure's renaming.
body.add(js.statement('let # = # && # in # ? #.# : #;', [
jsParam,
_namedArgumentTemp,
paramName,
_namedArgumentTemp,
_namedArgumentTemp,
paramName,
defaultValue,
]));
} else {
body.add(js.statement('let # = # && #.#;', [
jsParam,
_namedArgumentTemp,
_namedArgumentTemp,
paramName,
]));
}
body.add(js.statement('let # = # && # ? #.# : #;', [
jsParam,
_namedArgumentTemp,
_namedArgumentProbe(paramName),
_namedArgumentTemp,
paramName,
defaultValue,
]));

if (_checkParameters) {
initParameter(p, jsParam);
}
Expand Down Expand Up @@ -3878,16 +3867,24 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
return js.statement('if (# == null) #;', [param, call]);
}

js_ast.Expression? _defaultParamValue(VariableDeclaration p) {
if (p.annotations.any(isUndefinedAnnotation)) {
return null;
} else if (p.initializer != null) {
js_ast.Expression _defaultParamValue(VariableDeclaration p) {
if (p.initializer != null) {
return _visitExpression(p.initializer!);
} else {
return js_ast.LiteralNull();
}
}

/// Returns a test for the existence of [propertyName] in the named argument
/// package.
js_ast.Expression _namedArgumentProbe(js_ast.LiteralString propertyName) =>
// If the name collides with the names in the native JavaScript object
// prototype then use a slower but more direct test to avoid
// accidentally finding a value up the prototype chain.
js_ast.objectProperties.contains(propertyName.valueWithoutQuotes)
? _runtimeCall('hOP.call(#, #)', [_namedArgumentTemp, propertyName])
: js.call('# in #', [propertyName, _namedArgumentTemp]);

void _emitCovarianceBoundsCheck(
List< /* TypeParameter | StructuralParameter */ Object> typeFormals,
List<js_ast.Statement> body) {
Expand Down
8 changes: 0 additions & 8 deletions sdk/lib/_internal/js_dev_runtime/private/annotations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ class _NullCheck {
const _NullCheck();
}

/// Annotation indicating the parameter should default to the JavaScript
/// undefined constant.
const undefined = _Undefined();

class _Undefined {
const _Undefined();
}

/// Tells the development compiler to check a variable for null at its
/// declaration point, and then to assume that the variable is non-null
/// from that point forward.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,11 @@ validateFunctionToJSArgs(f, List args) {
return null;
}

dcall(f, args, [@undefined named]) => _checkAndCall(
dcall(f, args, [named]) => _checkAndCall(
f, null, JS('', 'void 0'), null, args, named, JS('', 'f.name'));

dgcall(f, typeArgs, args, [@undefined named]) => _checkAndCall(f, null,
JS('', 'void 0'), typeArgs, args, named, JS('', "f.name || 'call'"));
dgcall(f, typeArgs, args, [named]) => _checkAndCall(f, null, JS('', 'void 0'),
typeArgs, args, named, JS('', "f.name || 'call'"));

/// Helper for REPL dynamic invocation variants that make a best effort to
/// enable accessing private members across library boundaries.
Expand Down Expand Up @@ -514,16 +514,16 @@ callMethod(obj, name, typeArgs, args, named, displayName) {
return _checkAndCall(f, ftype, obj, typeArgs, args, named, displayName);
}

dsend(obj, method, args, [@undefined named]) =>
dsend(obj, method, args, [named]) =>
callMethod(obj, method, null, args, named, method);

dgsend(obj, typeArgs, method, args, [@undefined named]) =>
dgsend(obj, typeArgs, method, args, [named]) =>
callMethod(obj, method, typeArgs, args, named, method);

dsendRepl(obj, method, args, [@undefined named]) =>
dsendRepl(obj, method, args, [named]) =>
callMethod(obj, replNameLookup(obj, method), null, args, named, method);

dgsendRepl(obj, typeArgs, method, args, [@undefined named]) =>
dgsendRepl(obj, typeArgs, method, args, [named]) =>
callMethod(obj, replNameLookup(obj, method), typeArgs, args, named, method);

dindex(obj, index) => callMethod(obj, '_get', null, [index], null, '[]');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ void trackProfile(bool flag) {

final JsSymbol = JS('', 'Symbol');

/// An alias for the .hasOwnProperty function.
///
/// Used to test for the presence of properties packaged in a native JavaScript
/// Object when the property name matches one of the names on the native
/// JavaScript Object prototype.
final hOP = JS('!', '#.Object.prototype.hasOwnProperty', global_);

/// The prototype used for all Dart libraries.
///
/// This makes it easy to identify Dart library objects, and also improves
Expand Down
2 changes: 1 addition & 1 deletion tools/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ CHANNEL dev
MAJOR 3
MINOR 6
PATCH 0
PRERELEASE 84
PRERELEASE 85
PRERELEASE_PATCH 0

0 comments on commit 1b29ac3

Please sign in to comment.