Skip to content

Commit

Permalink
add a custom inliner for typeassert, to remove it earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 24, 2014
1 parent c300f5f commit e4ff09a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,13 @@ function inlineable(f, e::Expr, atypes, sv, enclosing_ast)
return (e.args[3],())
end
end
if is(f, typeassert) && length(atypes)==2
# typeassert(x::S, T) => x, when S<:T
if isType(atypes[2]) && isleaftype(atypes[2]) &&
atypes[1] <: atypes[2].parameters[1]
return (e.args[2],())
end
end
if length(atypes)==2 && is(f,unbox) && isa(atypes[2],DataType) && !atypes[2].mutable && atypes[2].pointerfree
# remove redundant unbox
return (e.args[3],())
Expand Down

0 comments on commit e4ff09a

Please sign in to comment.