@@ -1395,16 +1395,26 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
1395
1395
void emitSignature (String name, List <js_ast.Property > elements) {
1396
1396
if (elements.isEmpty) return ;
1397
1397
1398
+ js_ast.Statement setSignature;
1398
1399
if (! name.startsWith ('Static' )) {
1399
1400
var proto = c == _coreTypes.objectClass
1400
1401
? js.call ('Object.create(null)' )
1401
1402
: runtimeCall ('get${name }s(#.__proto__)' , [className]);
1402
1403
elements.insert (0 , js_ast.Property (propertyName ('__proto__' ), proto));
1404
+ setSignature = runtimeStatement ('set${name }Signature(#, () => #)' , [
1405
+ className,
1406
+ js_ast.ObjectInitializer (elements, multiline: elements.length > 1 )
1407
+ ]);
1408
+ } else {
1409
+ // TODO(40273) Only tagging with the names of static members until the
1410
+ // debugger consumes signature information from symbol files.
1411
+ setSignature = runtimeStatement ('set${name }Signature(#, () => #)' , [
1412
+ className,
1413
+ js_ast.ArrayInitializer (elements.map ((e) => e.name).toList ())
1414
+ ]);
1403
1415
}
1404
- body.add (runtimeStatement ('set${name }Signature(#, () => #)' , [
1405
- className,
1406
- js_ast.ObjectInitializer (elements, multiline: elements.length > 1 )
1407
- ]));
1416
+
1417
+ body.add (setSignature);
1408
1418
}
1409
1419
1410
1420
var extMethods = _classProperties.extensionMethods;
@@ -1416,6 +1426,8 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
1416
1426
var staticSetters = < js_ast.Property > [];
1417
1427
var instanceSetters = < js_ast.Property > [];
1418
1428
List <js_ast.Property > getSignatureList (Procedure p) {
1429
+ // TODO(40273) Skip for all statics when the debugger consumes signature
1430
+ // information from symbol files.
1419
1431
if (p.isStatic) {
1420
1432
if (p.isGetter) {
1421
1433
return staticGetters;
@@ -1437,9 +1449,14 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
1437
1449
1438
1450
var classProcedures = c.procedures.where ((p) => ! p.isAbstract).toList ();
1439
1451
for (var member in classProcedures) {
1440
- // Static getters/setters/methods cannot be called with dynamic dispatch,
1441
- // nor can they be torn off.
1442
- if (member.isStatic) continue ;
1452
+ // Static getters/setters cannot be called with dynamic dispatch or torn
1453
+ // off. Static methods can't be called with dynamic dispatch and are
1454
+ // tagged with a type when torn off. Most are implicitly const and
1455
+ // canonicalized. Static signatures are only used by the debugger and are
1456
+ // not needed for runtime correctness.
1457
+ // TODO(40273) Skip for all statics when the debugger consumes signature
1458
+ // information from symbol files.
1459
+ if (isTearOffLowering (member)) continue ;
1443
1460
1444
1461
var name = member.name.text;
1445
1462
var reifiedType = _memberRuntimeType (member, c) as FunctionType ;
@@ -1478,6 +1495,8 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
1478
1495
}
1479
1496
1480
1497
emitSignature ('Method' , instanceMethods);
1498
+ // TODO(40273) Skip for all statics when the debugger consumes signature
1499
+ // information from symbol files.
1481
1500
emitSignature ('StaticMethod' , staticMethods);
1482
1501
emitSignature ('Getter' , instanceGetters);
1483
1502
emitSignature ('Setter' , instanceSetters);
@@ -1491,16 +1510,19 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
1491
1510
1492
1511
var classFields = c.fields.toList ();
1493
1512
for (var field in classFields) {
1494
- // Only instance fields need to be saved for dynamic dispatch.
1495
- var isStatic = field.isStatic;
1496
- if (isStatic) continue ;
1497
-
1513
+ // Static fields cannot be called with dynamic dispatch or torn off. The
1514
+ // signatures are only used by the debugger and are not needed for runtime
1515
+ // correctness.
1498
1516
var memberName = _declareMemberName (field);
1499
1517
var fieldSig = _emitFieldSignature (field, c);
1500
- (isStatic ? staticFields : instanceFields)
1518
+ // TODO(40273) Skip static fields when the debugger consumes signature
1519
+ // information from symbol files.
1520
+ (field.isStatic ? staticFields : instanceFields)
1501
1521
.add (js_ast.Property (memberName, fieldSig));
1502
1522
}
1503
1523
emitSignature ('Field' , instanceFields);
1524
+ // TODO(40273) Skip for all statics when the debugger consumes signature
1525
+ // information from symbol files.
1504
1526
emitSignature ('StaticField' , staticFields);
1505
1527
1506
1528
// Add static property dart._runtimeType to Object.
@@ -2525,6 +2547,9 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
2525
2547
var exportName = _jsExportName (member);
2526
2548
if (exportName != null ) return propertyName (exportName);
2527
2549
}
2550
+ if (member is Procedure && member.isFactory) {
2551
+ return _constructorName (member.name.text);
2552
+ }
2528
2553
switch (name) {
2529
2554
// Reserved for the compiler to do `x as T`.
2530
2555
case 'as' :
0 commit comments