@@ -312,11 +312,9 @@ internal static MSAst.Expression TransformMaybeSingleLineSuite(Statement body, S
312312 }
313313
314314 internal static MSAst . Expression RemoveDebugInfo ( int prevStart , MSAst . Expression res ) {
315- MSAst . BlockExpression block = res as MSAst . BlockExpression ;
316- if ( block != null && block . Expressions . Count > 0 ) {
317- MSAst . DebugInfoExpression dbgInfo = block . Expressions [ 0 ] as MSAst . DebugInfoExpression ;
315+ if ( res is BlockExpression block && block . Expressions . Count > 0 ) {
318316 // body on the same line as an if, don't generate a 2nd sequence point
319- if ( dbgInfo != null && dbgInfo . StartLine == prevStart ) {
317+ if ( block . Expressions [ 0 ] is DebugInfoExpression dbgInfo && dbgInfo . StartLine == prevStart ) {
320318 // we remove the debug info based upon how it's generated in DebugStatement.AddDebugInfo which is
321319 // the helper method which adds the debug info.
322320 if ( block . Type == typeof ( void ) ) {
@@ -351,8 +349,7 @@ internal static MSAst.Expression RemoveFrame(MSAst.Expression expression) {
351349
352350 class FramedCodeVisitor : ExpressionVisitor {
353351 public override MSAst . Expression Visit ( MSAst . Expression node ) {
354- FramedCodeExpression framedCode = node as FramedCodeExpression ;
355- if ( framedCode != null ) {
352+ if ( node is FramedCodeExpression framedCode ) {
356353 return framedCode . Body ;
357354 }
358355 return base . Visit ( node ) ;
@@ -443,17 +440,15 @@ internal MSAst.Expression MakeAssignment(MSAst.ParameterExpression variable, MSA
443440 Debug . Assert ( expression != null ) ;
444441 Debug . Assert ( value != null ) ;
445442
446- IPythonVariableExpression pyGlobal = expression as IPythonVariableExpression ;
447- if ( pyGlobal != null ) {
443+ if ( expression is IPythonVariableExpression pyGlobal ) {
448444 return pyGlobal . Assign ( value ) ;
449445 }
450446
451447 return Ast . Assign ( expression , value ) ;
452448 }
453449
454450 internal static MSAst . Expression /*!*/ Delete ( MSAst . Expression /*!*/ expression ) {
455- IPythonVariableExpression pyGlobal = expression as IPythonVariableExpression ;
456- if ( pyGlobal != null ) {
451+ if ( expression is IPythonVariableExpression pyGlobal ) {
457452 return pyGlobal . Delete ( ) ;
458453 }
459454
0 commit comments