@@ -3449,22 +3449,28 @@ export class Compiler extends DiagnosticEmitter {
3449
3449
expr = this . module . unreachable ( ) ;
3450
3450
}
3451
3451
}
3452
- // debug location is added here so the caller doesn't have to. means: compilation of an expression
3453
- // must go through this function, with the respective per-kind functions not being used directly.
3454
- if ( this . options . sourceMap ) this . addDebugLocation ( expr , expression . range ) ;
3455
3452
// ensure conversion and wrapping in case the respective function doesn't on its own
3456
3453
let currentType = this . currentType ;
3457
3454
let wrap = ( constraints & Constraints . MustWrap ) != 0 ;
3458
3455
if ( currentType != contextualType . nonNullableType ) { // allow assigning non-nullable to nullable
3459
3456
if ( constraints & Constraints . ConvExplicit ) {
3457
+ // emit debug location for inner expression before conversion
3458
+ if ( this . options . sourceMap ) this . addDebugLocation ( expr , expression . range ) ;
3460
3459
expr = this . convertExpression ( expr , currentType , contextualType , true , expression ) ;
3461
3460
this . currentType = currentType = contextualType ;
3462
3461
} else if ( constraints & Constraints . ConvImplicit ) {
3462
+ if ( this . options . sourceMap ) this . addDebugLocation ( expr , expression . range ) ;
3463
3463
expr = this . convertExpression ( expr , currentType , contextualType , false , expression ) ;
3464
3464
this . currentType = currentType = contextualType ;
3465
3465
}
3466
3466
}
3467
- if ( wrap ) expr = this . ensureSmallIntegerWrap ( expr , currentType ) ;
3467
+ if ( wrap ) {
3468
+ if ( this . options . sourceMap ) this . addDebugLocation ( expr , expression . range ) ;
3469
+ expr = this . ensureSmallIntegerWrap ( expr , currentType ) ;
3470
+ }
3471
+ // debug location is added here so the caller doesn't have to. means: compilation of an expression
3472
+ // must go through this function, with the respective per-kind functions not being used directly.
3473
+ if ( this . options . sourceMap ) this . addDebugLocation ( expr , expression . range ) ;
3468
3474
return expr ;
3469
3475
}
3470
3476
0 commit comments