@@ -1232,9 +1232,10 @@ func (ctx *lowerClassContext) hoistComputedProperties(p *parser, classLoweringIn
1232
1232
for i , decorator := range analysis .propDecorators {
1233
1233
values [i ] = decorator .Value
1234
1234
}
1235
+ atLoc := analysis .propDecorators [0 ].AtLoc
1235
1236
decorators = js_ast .Assign (
1236
- js_ast.Expr {Loc : prop . Loc , Data : & js_ast.EIdentifier {Ref : ref }},
1237
- js_ast.Expr {Loc : prop . Loc , Data : & js_ast.EArray {Items : values , IsSingleLine : true }})
1237
+ js_ast.Expr {Loc : atLoc , Data : & js_ast.EIdentifier {Ref : ref }},
1238
+ js_ast.Expr {Loc : atLoc , Data : & js_ast.EArray {Items : values , IsSingleLine : true }})
1238
1239
p .recordUsage (ref )
1239
1240
if decoratorTempRefs == nil {
1240
1241
decoratorTempRefs = make (map [int ]ast.Ref )
@@ -1483,12 +1484,13 @@ func (ctx *lowerClassContext) processProperties(p *parser, classLoweringInfo cla
1483
1484
for i , decorator := range ctx .class .Decorators {
1484
1485
values [i ] = decorator .Value
1485
1486
}
1487
+ atLoc := ctx .class .Decorators [0 ].AtLoc
1486
1488
ctx .computedPropertyChain = js_ast .JoinWithComma (js_ast .Assign (
1487
- js_ast.Expr {Loc : ctx . classLoc , Data : & js_ast.EIdentifier {Ref : decoratorsRef }},
1488
- js_ast.Expr {Loc : ctx . classLoc , Data : & js_ast.EArray {Items : values , IsSingleLine : true }},
1489
+ js_ast.Expr {Loc : atLoc , Data : & js_ast.EIdentifier {Ref : decoratorsRef }},
1490
+ js_ast.Expr {Loc : atLoc , Data : & js_ast.EArray {Items : values , IsSingleLine : true }},
1489
1491
), ctx .computedPropertyChain )
1490
1492
p .recordUsage (decoratorsRef )
1491
- ctx .decoratorClassDecorators = js_ast.Expr {Loc : ctx . classLoc , Data : & js_ast.EIdentifier {Ref : decoratorsRef }}
1493
+ ctx .decoratorClassDecorators = js_ast.Expr {Loc : atLoc , Data : & js_ast.EIdentifier {Ref : decoratorsRef }}
1492
1494
p .recordUsage (decoratorsRef )
1493
1495
ctx .class .Decorators = nil
1494
1496
}
@@ -1594,7 +1596,9 @@ func (ctx *lowerClassContext) processProperties(p *parser, classLoweringInfo cla
1594
1596
initializerIndex := - 1
1595
1597
if len (analysis .propDecorators ) > 0 {
1596
1598
prop .Decorators = nil
1597
- loc := prop .Key .Loc
1599
+ loc := prop .Loc
1600
+ keyLoc := prop .Key .Loc
1601
+ atLoc := analysis .propDecorators [0 ].AtLoc
1598
1602
1599
1603
// Encode information about this property using bit flags
1600
1604
var flags int
@@ -1635,7 +1639,7 @@ func (ctx *lowerClassContext) processProperties(p *parser, classLoweringInfo cla
1635
1639
{Loc : loc , Data : & js_ast.EIdentifier {Ref : ctx .decoratorContextRef }},
1636
1640
{Loc : loc , Data : & js_ast.ENumber {Value : float64 (flags )}},
1637
1641
key ,
1638
- {Loc : loc , Data : & js_ast.EIdentifier {Ref : decoratorsRef }},
1642
+ {Loc : atLoc , Data : & js_ast.EIdentifier {Ref : decoratorsRef }},
1639
1643
}
1640
1644
p .recordUsage (ctx .decoratorContextRef )
1641
1645
p .recordUsage (decoratorsRef )
@@ -1644,7 +1648,7 @@ func (ctx *lowerClassContext) processProperties(p *parser, classLoweringInfo cla
1644
1648
privateFnRef := ast .InvalidRef
1645
1649
if analysis .private != nil {
1646
1650
// Add the "target" argument (the weak set)
1647
- args = append (args , js_ast.Expr {Loc : loc , Data : & js_ast.EIdentifier {Ref : analysis .private .Ref }})
1651
+ args = append (args , js_ast.Expr {Loc : keyLoc , Data : & js_ast.EIdentifier {Ref : analysis .private .Ref }})
1648
1652
p .recordUsage (analysis .private .Ref )
1649
1653
1650
1654
// Add the "extra" argument (the function)
@@ -1657,7 +1661,7 @@ func (ctx *lowerClassContext) processProperties(p *parser, classLoweringInfo cla
1657
1661
privateFnRef = p .privateSetters [analysis .private .Ref ]
1658
1662
}
1659
1663
if privateFnRef != ast .InvalidRef {
1660
- args = append (args , js_ast.Expr {Loc : loc , Data : & js_ast.EIdentifier {Ref : privateFnRef }})
1664
+ args = append (args , js_ast.Expr {Loc : keyLoc , Data : & js_ast.EIdentifier {Ref : privateFnRef }})
1661
1665
p .recordUsage (privateFnRef )
1662
1666
}
1663
1667
} else {
@@ -1675,14 +1679,14 @@ func (ctx *lowerClassContext) processProperties(p *parser, classLoweringInfo cla
1675
1679
1676
1680
// Pass the WeakMap instance into the decorator helper
1677
1681
autoAccessorWeakMapRef = p .generateTempRef (tempRefNeedsDeclare , p .propertyNameHint (prop .Key , "" ))
1678
- args = append (args , js_ast.Expr {Loc : loc , Data : & js_ast.EIdentifier {Ref : autoAccessorWeakMapRef }})
1682
+ args = append (args , js_ast.Expr {Loc : keyLoc , Data : & js_ast.EIdentifier {Ref : autoAccessorWeakMapRef }})
1679
1683
p .recordUsage (autoAccessorWeakMapRef )
1680
1684
}
1681
1685
1682
1686
// Assign the result
1683
1687
element := p .callRuntime (loc , "__decorateElement" , args )
1684
1688
if privateFnRef != ast .InvalidRef {
1685
- element = js_ast .Assign (js_ast.Expr {Loc : loc , Data : & js_ast.EIdentifier {Ref : privateFnRef }}, element )
1689
+ element = js_ast .Assign (js_ast.Expr {Loc : keyLoc , Data : & js_ast.EIdentifier {Ref : privateFnRef }}, element )
1686
1690
p .recordUsage (privateFnRef )
1687
1691
} else if prop .Kind == js_ast .PropertyAutoAccessor && analysis .private != nil {
1688
1692
ref := p .generateTempRef (tempRefNeedsDeclare , "" )
@@ -1697,10 +1701,10 @@ func (ctx *lowerClassContext) processProperties(p *parser, classLoweringInfo cla
1697
1701
js_ast.Expr {Loc : loc , Data : & js_ast.EIdentifier {Ref : ref }},
1698
1702
element ),
1699
1703
js_ast .Assign (
1700
- js_ast.Expr {Loc : loc , Data : & js_ast.EIdentifier {Ref : privateGetFnRef }},
1704
+ js_ast.Expr {Loc : keyLoc , Data : & js_ast.EIdentifier {Ref : privateGetFnRef }},
1701
1705
js_ast.Expr {Loc : loc , Data : & js_ast.EDot {Target : js_ast.Expr {Loc : loc , Data : & js_ast.EIdentifier {Ref : ref }}, Name : "get" , NameLoc : loc }})),
1702
1706
js_ast .Assign (
1703
- js_ast.Expr {Loc : loc , Data : & js_ast.EIdentifier {Ref : privateSetFnRef }},
1707
+ js_ast.Expr {Loc : keyLoc , Data : & js_ast.EIdentifier {Ref : privateSetFnRef }},
1704
1708
js_ast.Expr {Loc : loc , Data : & js_ast.EDot {Target : js_ast.Expr {Loc : loc , Data : & js_ast.EIdentifier {Ref : ref }}, Name : "set" , NameLoc : loc }}))
1705
1709
p .recordUsage (ref )
1706
1710
p .recordUsage (privateGetFnRef )
0 commit comments