get_current_screen – ‘Trying to get property of non-object’ error

I tested this code and it worked fine. Where are you requireing screen.php? Same way as this?

require_once(ABSPATH . 'wp-admin/includes/screen.php');
add_action( 'parse_query', 'filtering_edit_table' );

function filtering_edit_table( $query ) {
    $screen = get_current_screen();

    if( is_admin() && $screen->post_type == 'custom_post_type' && $screen->base == 'edit' ) {
        print_r($screen);
    }
}