Skip to content

Commit af24e99

Browse files
MarkzipanCommit Queue
authored andcommitted
[ddc] Attaching default type arg member signatures to JS native types.
Fixes 'member not found' issues arising from accessing default type arguments from JS literals. Change-Id: I7cdfddcd70ee42a2941c8cb666570e161077281b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307513 Reviewed-by: Nicholas Shahan <[email protected]> Commit-Queue: Mark Zhou <[email protected]>
1 parent 565379a commit af24e99

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/classes.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,10 @@ void _installPropertiesForGlobalObject(jsProto) {
484484

485485
final _extensionMap = JS('', 'new Map()');
486486

487+
/// Adds Dart properties to native JS types.
487488
void _applyExtension(jsType, dartExtType) {
488-
// TODO(vsm): Not all registered js types are real.
489+
// Exit early when encountering a JS type without a prototype (such as
490+
// structs).
489491
if (jsType == null) return;
490492
var jsProto = JS<Object?>('', '#.prototype', jsType);
491493
if (jsProto == null) return;
@@ -509,7 +511,11 @@ void _applyExtension(jsType, dartExtType) {
509511
if (JS('!', '# !== #', dartExtType, JS_CLASS_REF(JSFunction))) {
510512
JS('', '#[#] = #', jsProto, _extensionType, dartExtType);
511513
}
514+
515+
// Attach member signature tags.
512516
JS('', '#[#] = #[#]', jsType, _methodSig, dartExtType, _methodSig);
517+
JS('', '#[#] = #[#]', jsType, _methodsDefaultTypeArgSig, dartExtType,
518+
_methodsDefaultTypeArgSig);
513519
JS('', '#[#] = #[#]', jsType, _fieldSig, dartExtType, _fieldSig);
514520
JS('', '#[#] = #[#]', jsType, _getterSig, dartExtType, _getterSig);
515521
JS('', '#[#] = #[#]', jsType, _setterSig, dartExtType, _setterSig);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Tests that generic function invocations have their default type arguments
6+
// resolved in a dynamic call when the type argument is a JS entity.
7+
8+
void main() {
9+
dynamic arrayLiteral = [];
10+
arrayLiteral.map((v) => '$v');
11+
}

0 commit comments

Comments
 (0)