[dart2js] Handle JS interop functions with more than 52 parameters.

Attached test fails without this new change in place.

Bug: https://github.com/dart-lang/sdk/issues/62528
Change-Id: I7b658b9a404294678f9f94e93da490dcd975c7e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476260
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
Nate Biggs
2026-01-28 15:33:35 -08:00
committed by Commit Queue
parent e022f92659
commit c2f0ff4739
2 changed files with 196 additions and 3 deletions
@@ -14,6 +14,21 @@ import '../universe/world_builder.dart' show SelectorConstraints;
import 'namer.dart';
import 'native_data.dart';
const String _candidateParameterNames =
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
String _generateParameterName(int index) {
final StringBuffer buffer = StringBuffer();
while (index >= _candidateParameterNames.length) {
buffer.write(
_candidateParameterNames[index % _candidateParameterNames.length],
);
index = index ~/ _candidateParameterNames.length;
}
buffer.write(_candidateParameterNames[index]);
return buffer.toString();
}
js_ast.Statement? buildJsInteropBootstrap(
CodegenWorld codegenWorld,
NativeBasicData nativeBasicData,
@@ -30,11 +45,9 @@ js_ast.Statement? buildJsInteropBootstrap(
// TODO(jacobr): support named arguments.
if (selector.namedArgumentCount > 0) return;
int argumentCount = selector.argumentCount;
String candidateParameterNames =
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
List<String> parameters = List<String>.generate(
argumentCount,
(i) => candidateParameterNames[i],
_generateParameterName,
);
js_ast.Name name = namer.invocationName(selector);
+180
View File
@@ -0,0 +1,180 @@
// Copyright (c) 2026, 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.
import 'dart:js_interop';
@JS()
extension type Bar(JSObject o) {}
class Foo {
void foo(
int a,
int b,
int c,
int d,
int e,
int f,
int g,
int h,
int i,
int j,
int k,
int l,
int m,
int n,
int o,
int p,
int q,
int r,
int s,
int t,
int u,
int v,
int w,
int x,
int y,
int z,
int aa,
int ab,
int ac,
int ad,
int ae,
int af,
int ag,
int ah,
int ai,
int aj,
int ak,
int al,
int am,
int an,
int ao,
int ap,
int aq,
int ar,
int as,
int at,
int au,
int av,
int aw,
int ax,
int ay,
int az,
int aaa,
) {
print(a);
print(b);
print(c);
print(d);
print(e);
print(f);
print(g);
print(h);
print(i);
print(j);
print(k);
print(l);
print(m);
print(n);
print(o);
print(p);
print(q);
print(r);
print(s);
print(t);
print(u);
print(v);
print(w);
print(x);
print(y);
print(z);
print(aa);
print(ab);
print(ac);
print(ad);
print(ae);
print(af);
print(ag);
print(ah);
print(ai);
print(aj);
print(ak);
print(al);
print(am);
print(an);
print(ao);
print(ap);
print(aq);
print(ar);
print(as);
print(at);
print(au);
print(av);
print(aw);
print(ax);
print(ay);
print(az);
print(aaa);
}
}
void main() {
final bar = Bar(JSObject());
final f = Foo().foo;
f(
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
);
}