Skip to content

[ddc] Duplicated member signature information on some classes #52867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nshahan opened this issue Jul 6, 2023 · 0 comments
Open

[ddc] Duplicated member signature information on some classes #52867

nshahan opened this issue Jul 6, 2023 · 0 comments
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. P3 A lower priority bug or feature request web-dev-compiler

Comments

@nshahan
Copy link
Contributor

nshahan commented Jul 6, 2023

In the compiled output, some classes have duplicated member signature information attached to them. For example, see the Iterable class in the compiled output:

class Iterable extends core.Object {
  ...
}
...
dart.setMethodSignature(Iterable, () => dart.global.Object.setPrototypeOf({
  cast: dart.gFnType(R => [core.Iterable$(R), []], R => [dart.nullable(core.Object)]),
  [$cast]: dart.gFnType(R => [core.Iterable$(R), []], R => [dart.nullable(core.Object)]),
  followedBy: dart.fnType(core.Iterable$(E), [dart.nullable(core.Object)]),
  [$followedBy]: dart.fnType(core.Iterable$(E), [dart.nullable(core.Object)]),
  map: dart.gFnType(T => [core.Iterable$(T), [dart.fnType(T, [E])]], T => [dart.nullable(core.Object)]),
  [$map]: dart.gFnType(T => [core.Iterable$(T), [dart.fnType(T, [E])]], T => [dart.nullable(core.Object)]),
  where: dart.fnType(core.Iterable$(E), [dart.fnType(core.bool, [E])]),
  [$where]: dart.fnType(core.Iterable$(E), [dart.fnType(core.bool, [E])]),
  whereType: dart.gFnType(T => [core.Iterable$(T), []], T => [dart.nullable(core.Object)]),
  [$whereType]: dart.gFnType(T => [core.Iterable$(T), []], T => [dart.nullable(core.Object)]),
  expand: dart.gFnType(T => [core.Iterable$(T), [dart.fnType(core.Iterable$(T), [E])]], T => [dart.nullable(core.Object)]),
  [$expand]: dart.gFnType(T => [core.Iterable$(T), [dart.fnType(core.Iterable$(T), [E])]], T => [dart.nullable(core.Object)]),
  contains: dart.fnType(core.bool, [dart.nullable(core.Object)]),
  [$contains]: dart.fnType(core.bool, [dart.nullable(core.Object)]),
  forEach: dart.fnType(dart.void, [dart.fnType(dart.void, [E])]),
  [$forEach]: dart.fnType(dart.void, [dart.fnType(dart.void, [E])]),
  reduce: dart.fnType(E, [dart.nullable(core.Object)]),
  [$reduce]: dart.fnType(E, [dart.nullable(core.Object)]),
  fold: dart.gFnType(T => [T, [T, dart.fnType(T, [T, E])]], T => [dart.nullable(core.Object)]),
  [$fold]: dart.gFnType(T => [T, [T, dart.fnType(T, [T, E])]], T => [dart.nullable(core.Object)]),
  every: dart.fnType(core.bool, [dart.fnType(core.bool, [E])]),
  [$every]: dart.fnType(core.bool, [dart.fnType(core.bool, [E])]),
  join: dart.fnType(core.String, [], [core.String]),
  [$join]: dart.fnType(core.String, [], [core.String]),
  any: dart.fnType(core.bool, [dart.fnType(core.bool, [E])]),
  [$any]: dart.fnType(core.bool, [dart.fnType(core.bool, [E])]),
  toList: dart.fnType(core.List$(E), [], {growable: core.bool}, {}),
  [$toList]: dart.fnType(core.List$(E), [], {growable: core.bool}, {}),
  toSet: dart.fnType(core.Set$(E), []),
  [$toSet]: dart.fnType(core.Set$(E), []),
  take: dart.fnType(core.Iterable$(E), [core.int]),
  [$take]: dart.fnType(core.Iterable$(E), [core.int]),
  takeWhile: dart.fnType(core.Iterable$(E), [dart.fnType(core.bool, [E])]),
  [$takeWhile]: dart.fnType(core.Iterable$(E), [dart.fnType(core.bool, [E])]),
  skip: dart.fnType(core.Iterable$(E), [core.int]),
  [$skip]: dart.fnType(core.Iterable$(E), [core.int]),
  skipWhile: dart.fnType(core.Iterable$(E), [dart.fnType(core.bool, [E])]),
  [$skipWhile]: dart.fnType(core.Iterable$(E), [dart.fnType(core.bool, [E])]),
  firstWhere: dart.fnType(E, [dart.fnType(core.bool, [E])], {orElse: dart.nullable(core.Object)}, {}),
  [$firstWhere]: dart.fnType(E, [dart.fnType(core.bool, [E])], {orElse: dart.nullable(core.Object)}, {}),
  lastWhere: dart.fnType(E, [dart.fnType(core.bool, [E])], {orElse: dart.nullable(core.Object)}, {}),
  [$lastWhere]: dart.fnType(E, [dart.fnType(core.bool, [E])], {orElse: dart.nullable(core.Object)}, {}),
  singleWhere: dart.fnType(E, [dart.fnType(core.bool, [E])], {orElse: dart.nullable(core.Object)}, {}),
  [$singleWhere]: dart.fnType(E, [dart.fnType(core.bool, [E])], {orElse: dart.nullable(core.Object)}, {}),
  elementAt: dart.fnType(E, [core.int]),
  [$elementAt]: dart.fnType(E, [core.int])
}, dart.getMethods(dart.global.Object.getPrototypeOf(Iterable))));

Each method has the same signature added twice, once with just a name and once with a "symbolized" name. I couldn't remove either of them without some tests failing so there must be some inconsistency in how we access the signatures at runtime.

Not all classes exhibit this pattern. Most have either just a name or just a symbol. It looks like the duplication was added long ago in the analyzer based version and it persisted when ported to kernel 749d298.

With the new runtime type system this issue also appears with the default type arguments for the instance methods that have type parameters. In order to be consistent with the method signature I had to duplicate them in the same way to get all of the lookups to work at runtime.

@nshahan nshahan added P3 A lower priority bug or feature request web-dev-compiler area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. labels Jul 6, 2023
copybara-service bot pushed a commit that referenced this issue Jul 6, 2023
- They should match the calling convention and use the "dartx" symbol.
- Skip adding signatures for static methods since they can't be
  called dynamically anyway.

Issue: #48585
Issue: #52867
Change-Id: If5a76f52163b2267129880dbfe8d145a3fd93408
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312204
Reviewed-by: Mark Zhou <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. P3 A lower priority bug or feature request web-dev-compiler
Projects
None yet
Development

No branches or pull requests

1 participant