mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 06:20:13 +00:00
[dart2wasm] Fix bug in dartify.
Change-Id: Ia922d3ac6e3849db13877259c65c7d8d884c5828 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262100 Commit-Queue: Joshua Litt <joshualitt@google.com> Reviewed-by: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
parent
53447c990f
commit
c6b141e9e5
2 changed files with 28 additions and 0 deletions
|
@ -188,6 +188,18 @@ Object? dartify(Object? object) {
|
|||
if (convertedObjects.containsKey(o)) {
|
||||
return convertedObjects[o];
|
||||
}
|
||||
|
||||
// Because [List] needs to be shallowly converted across the interop
|
||||
// boundary, we have to double check for the case where a shallowly
|
||||
// converted [List] is passed back into [dartify].
|
||||
if (o is List) {
|
||||
List<Object?> converted = [];
|
||||
for (final item in o) {
|
||||
converted.add(convert(item));
|
||||
}
|
||||
return converted;
|
||||
}
|
||||
|
||||
if (o is! JSValue) {
|
||||
return o;
|
||||
}
|
||||
|
|
|
@ -217,6 +217,10 @@ void deepConversionsTest() {
|
|||
10004.888]);
|
||||
globalThis.arrayBuffer = globalThis.uint8Array.buffer;
|
||||
globalThis.dataView = new DataView(globalThis.arrayBuffer);
|
||||
globalThis.implicitExplicit = [
|
||||
{'foo': 'bar'},
|
||||
[1, 2, 3, {'baz': 'boo'}],
|
||||
];
|
||||
''');
|
||||
Object gt = globalThis;
|
||||
Expect.isNull(getProperty(gt, 'a'));
|
||||
|
@ -264,6 +268,18 @@ void deepConversionsTest() {
|
|||
// Confirm a function that takes a roundtrip remains a function.
|
||||
Expect.equals('hello world',
|
||||
callMethod(gt, 'invoke', <Object?>[dartify(getProperty(gt, 'f'))]));
|
||||
|
||||
// Confirm arrays, which need to be converted implicitly, are still
|
||||
// recursively converted by dartify when desired.
|
||||
_expectIterableEquals([
|
||||
{'foo': 'bar'},
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
{'baz': 'boo'}
|
||||
],
|
||||
], dartify(getProperty(globalThis, 'implicitExplicit')) as Iterable);
|
||||
}
|
||||
|
||||
Future<void> promiseToFutureTest() async {
|
||||
|
|
Loading…
Reference in a new issue