@@ -1134,7 +1134,11 @@ impl Pure<'_> {
1134
1134
callee : Callee :: Expr ( callee) ,
1135
1135
args,
1136
1136
..
1137
- } ) if callee. is_one_of_global_ref_to ( self . expr_ctx , & [ "Array" , "Object" , "RegExp" ] ) => {
1137
+ } ) if callee. is_one_of_global_ref_to (
1138
+ self . expr_ctx . unresolved_ctxt ,
1139
+ & [ "Array" , "Object" , "RegExp" ] ,
1140
+ ) =>
1141
+ {
1138
1142
let new_expr = match & * * callee {
1139
1143
Expr :: Ident ( Ident { sym, .. } ) if & * * sym == "RegExp" => {
1140
1144
self . optimize_regex ( args, span)
@@ -1163,7 +1167,7 @@ impl Pure<'_> {
1163
1167
args,
1164
1168
..
1165
1169
} ) if callee. is_one_of_global_ref_to (
1166
- self . expr_ctx ,
1170
+ self . expr_ctx . unresolved_ctxt ,
1167
1171
& [ "Boolean" , "Number" , "String" , "Symbol" ] ,
1168
1172
) =>
1169
1173
{
@@ -1273,7 +1277,7 @@ impl Pure<'_> {
1273
1277
args,
1274
1278
..
1275
1279
} ) if callee. is_one_of_global_ref_to (
1276
- self . expr_ctx ,
1280
+ self . expr_ctx . unresolved_ctxt ,
1277
1281
& [
1278
1282
"Object" ,
1279
1283
// https://262.ecma-international.org/12.0/#sec-array-constructor
@@ -1292,7 +1296,7 @@ impl Pure<'_> {
1292
1296
"TypeError" ,
1293
1297
"URIError" ,
1294
1298
] ,
1295
- ) || ( callee. is_global_ref_to ( self . expr_ctx , "RegExp" )
1299
+ ) || ( callee. is_global_ref_to ( self . expr_ctx . unresolved_ctxt , "RegExp" )
1296
1300
&& can_compress_new_regexp ( args. as_deref ( ) ) ) =>
1297
1301
{
1298
1302
self . changed = true ;
@@ -1615,7 +1619,7 @@ impl Pure<'_> {
1615
1619
callee : Callee :: Expr ( callee) ,
1616
1620
args,
1617
1621
..
1618
- } ) if callee. is_pure_callee ( self . expr_ctx ) => {
1622
+ } ) if callee. is_pure_callee ( self . expr_ctx . unresolved_ctxt ) => {
1619
1623
report_change ! ( "ignore_return_value: Dropping a pure call (callee is pure)" ) ;
1620
1624
self . changed = true ;
1621
1625
@@ -1644,7 +1648,9 @@ impl Pure<'_> {
1644
1648
ctxt,
1645
1649
args,
1646
1650
..
1647
- } ) if callee. is_pure_callee ( self . expr_ctx ) || ctxt. has_mark ( self . marks . pure ) => {
1651
+ } ) if callee. is_pure_callee ( self . expr_ctx . unresolved_ctxt )
1652
+ || ctxt. has_mark ( self . marks . pure ) =>
1653
+ {
1648
1654
report_change ! ( "ignore_return_value: Dropping a pure call" ) ;
1649
1655
self . changed = true ;
1650
1656
@@ -1667,7 +1673,7 @@ impl Pure<'_> {
1667
1673
args,
1668
1674
..
1669
1675
} ) => {
1670
- if callee. is_pure_callee ( self . expr_ctx ) {
1676
+ if callee. is_pure_callee ( self . expr_ctx . unresolved_ctxt ) {
1671
1677
self . changed = true ;
1672
1678
report_change ! ( "Dropping pure call as callee is pure" ) ;
1673
1679
* e = self
@@ -1683,7 +1689,7 @@ impl Pure<'_> {
1683
1689
tpl,
1684
1690
..
1685
1691
} ) => {
1686
- if callee. is_pure_callee ( self . expr_ctx ) {
1692
+ if callee. is_pure_callee ( self . expr_ctx . unresolved_ctxt ) {
1687
1693
self . changed = true ;
1688
1694
report_change ! ( "Dropping pure tag tpl as callee is pure" ) ;
1689
1695
* e = self
@@ -2157,7 +2163,7 @@ impl Pure<'_> {
2157
2163
Expr :: New ( NewExpr {
2158
2164
span, callee, args, ..
2159
2165
} ) if callee. is_one_of_global_ref_to (
2160
- self . expr_ctx ,
2166
+ self . expr_ctx . unresolved_ctxt ,
2161
2167
& [
2162
2168
"Map" , "Set" , "Array" , "Object" , "Boolean" , "Number" , "String" ,
2163
2169
] ,
@@ -2181,7 +2187,7 @@ impl Pure<'_> {
2181
2187
args,
2182
2188
..
2183
2189
} ) if callee. is_one_of_global_ref_to (
2184
- self . expr_ctx ,
2190
+ self . expr_ctx . unresolved_ctxt ,
2185
2191
& [ "Array" , "Object" , "Boolean" , "Number" ] ,
2186
2192
) =>
2187
2193
{
@@ -2422,8 +2428,12 @@ impl Pure<'_> {
2422
2428
_ => return ,
2423
2429
} ;
2424
2430
2425
- let lt = cond. cons . get_type ( self . expr_ctx ) ;
2426
- let rt = cond. alt . get_type ( self . expr_ctx ) ;
2431
+ let lt = cond
2432
+ . cons
2433
+ . get_type ( self . expr_ctx . unresolved_ctxt , self . expr_ctx . remaining_depth ) ;
2434
+ let rt = cond
2435
+ . alt
2436
+ . get_type ( self . expr_ctx . unresolved_ctxt , self . expr_ctx . remaining_depth ) ;
2427
2437
match ( lt, rt) {
2428
2438
( Known ( Type :: Bool ) , Known ( Type :: Bool ) ) => { }
2429
2439
_ => return ,
0 commit comments