Fix jsinterop bug: we incorrectly added null values for js-interop constructor

calls.

Closes https://github.com/dart-lang/sdk/issues/32697

Change-Id: I7f372e9f32ec415f5d0e1472c04085029f41d5b9
Reviewed-on: https://dart-review.googlesource.com/48522
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Sigmund Cherem 2018-03-28 00:06:04 +00:00 committed by commit-bot@chromium.org
parent 8e02ff92db
commit 577b168c39
3 changed files with 35 additions and 3 deletions

View file

@ -4318,7 +4318,6 @@ class KernelSsaGraphBuilder extends ir.Visitor
return;
}
// TODO(sra): For JS-interop targets, process arguments differently.
List<HInstruction> arguments = <HInstruction>[];
if (constructor.isGenerativeConstructor &&
nativeData.isNativeOrExtendsNative(constructor.enclosingClass) &&
@ -4328,8 +4327,10 @@ class KernelSsaGraphBuilder extends ir.Visitor
}
List<DartType> typeArguments =
_getConstructorTypeArguments(constructor, node.arguments);
arguments.addAll(_visitArgumentsForStaticTarget(
target.function, node.arguments, typeArguments, sourceInformation));
arguments.addAll(closedWorld.nativeData.isJsInteropMember(constructor)
? _visitArgumentsForNativeStaticTarget(target.function, node.arguments)
: _visitArgumentsForStaticTarget(
target.function, node.arguments, typeArguments, sourceInformation));
if (commonElements.isSymbolConstructor(constructor)) {
constructor = commonElements.symbolValidatedConstructor;
}

View file

@ -95,6 +95,7 @@ closure_signature_unneeded_test: RuntimeError # Too eager signature generation.
deferred_custom_loader_test: SkipByDesign # Issue 25683
deferred_fail_and_retry_test: SkipByDesign # Uses eval to simulate failed loading.
deferred_fail_and_retry_worker_test: SkipByDesign # Uses eval to simulate failed loading.
js_interop_optional_arg_test: RuntimeError # Issue 31082
js_interop_test: RuntimeError # Issue 31082
[ $compiler == dart2js && $fast_startup ]

View file

@ -0,0 +1,30 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/// Test that optional arguments of js-interop constructors are not passed
/// explicitly when missing.
///
/// This is a regression test for issue 32697
import "package:js/js.dart";
import "package:expect/expect.dart";
import "dart:js" as js;
@JS('C')
class C {
external C([a]);
external bool get isUndefined;
}
main() {
js.context.callMethod("eval", [
"""
function C(a){
this.isUndefined = a === undefined;
};
"""
]);
Expect.isTrue(new C().isUndefined);
}