Lower CoerceType blocks into Filter blocks with a type-check predicate.

def lower_coerce_type_blocks(ir_blocks):
    """Lower CoerceType blocks into Filter blocks with a type-check predicate."""
    new_ir_blocks = []

    for block in ir_blocks:
        new_block = block
        if isinstance(block, CoerceType):
            predicate = BinaryComposition(
                u'contains', Literal(list(block.target_class)), LocalField('@class'))
            new_block = Filter(predicate)

        new_ir_blocks.append(new_block)

    return new_ir_blocks