Skip to content

Commit 5ca8325

Browse files
nshahanCommit Queue
authored and
Commit Queue
committed
[ddc] Fix default type args signature on native classes
- 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]>
1 parent e62748f commit 5ca8325

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pkg/dev_compiler/lib/src/kernel/compiler.dart

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
17301730
} else {
17311731
type = visitFunctionType(reifiedType);
17321732
if (_options.newRuntimeTypes &&
1733+
!member.isStatic &&
17331734
reifiedType.typeParameters.isNotEmpty) {
17341735
// Instance methods with generic type parameters require extra
17351736
// information to support dynamic calls. The default values for the
@@ -1739,15 +1740,26 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
17391740
for (var parameter in reifiedType.typeParameters)
17401741
_emitType(parameter.defaultType)
17411742
]);
1742-
var property = js_ast.Property(memberName, defaultTypeArgs);
1743-
instanceMethodsDefaultTypeArgs.add(property);
1743+
instanceMethodsDefaultTypeArgs
1744+
.add(js_ast.Property(memberName, defaultTypeArgs));
1745+
// As seen below, sometimes the member signatures are added again
1746+
// using the extension symbol as the name. That logic is duplicated
1747+
// here to ensure there are always default type arguments accessible
1748+
// via the same name as the signature.
1749+
// TODO(52867): Cleanup default type argument duplication.
1750+
if (extMethods.contains(name) || extAccessors.contains(name)) {
1751+
instanceMethodsDefaultTypeArgs.add(js_ast.Property(
1752+
_declareMemberName(member, useExtension: true),
1753+
defaultTypeArgs));
1754+
}
17441755
}
17451756
}
17461757
var property = js_ast.Property(memberName, type);
17471758
var signatures = getSignatureList(member);
17481759
signatures.add(property);
17491760
if (!member.isStatic &&
17501761
(extMethods.contains(name) || extAccessors.contains(name))) {
1762+
// TODO(52867): Cleanup signature duplication.
17511763
signatures.add(js_ast.Property(
17521764
_declareMemberName(member, useExtension: true), type));
17531765
}

0 commit comments

Comments
 (0)