private boolean removeUnreachable ( Block block ) { List < Statement > stmts = block . getStatements ( ) ; for ( int i = 0 ; i < stmts . size ( ) ; i ++ ) { Statement stmt = stmts . get ( i ) ; if ( stmt instanceof ReturnStatement || ( stmt instanceof Block && removeUnreachable ( ( Block ) stmt ) ) ) { stmts . subList ( i + 1 , stmts . size ( ) ) . clear ( ) ; return true ; } } return false ; }
Removes all unreachable statements that occur after a return statement in the given Block . Also recurses into child blocks .