Skip to content

Commit

Permalink
[ddc] Fix default type args signature on native classes
Browse files Browse the repository at this point in the history
- 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]>
  • Loading branch information
nshahan authored and Commit Queue committed Jul 6, 2023
1 parent e62748f commit 5ca8325
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pkg/dev_compiler/lib/src/kernel/compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
} else {
type = visitFunctionType(reifiedType);
if (_options.newRuntimeTypes &&
!member.isStatic &&
reifiedType.typeParameters.isNotEmpty) {
// Instance methods with generic type parameters require extra
// information to support dynamic calls. The default values for the
Expand All @@ -1739,15 +1740,26 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
for (var parameter in reifiedType.typeParameters)
_emitType(parameter.defaultType)
]);
var property = js_ast.Property(memberName, defaultTypeArgs);
instanceMethodsDefaultTypeArgs.add(property);
instanceMethodsDefaultTypeArgs
.add(js_ast.Property(memberName, defaultTypeArgs));
// As seen below, sometimes the member signatures are added again
// using the extension symbol as the name. That logic is duplicated
// here to ensure there are always default type arguments accessible
// via the same name as the signature.
// TODO(52867): Cleanup default type argument duplication.
if (extMethods.contains(name) || extAccessors.contains(name)) {
instanceMethodsDefaultTypeArgs.add(js_ast.Property(
_declareMemberName(member, useExtension: true),
defaultTypeArgs));
}
}
}
var property = js_ast.Property(memberName, type);
var signatures = getSignatureList(member);
signatures.add(property);
if (!member.isStatic &&
(extMethods.contains(name) || extAccessors.contains(name))) {
// TODO(52867): Cleanup signature duplication.
signatures.add(js_ast.Property(
_declareMemberName(member, useExtension: true), type));
}
Expand Down

0 comments on commit 5ca8325

Please sign in to comment.