Skip to content

Commit

Permalink
Make @inferred work for functions that return types
Browse files Browse the repository at this point in the history
  • Loading branch information
simonster committed Jan 15, 2015
1 parent de2feff commit 64ad746
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ macro inferred(ex)
inftypes = Base.return_types($(esc(ex.args[1])), Base.typesof(vals...))
@assert length(inftypes) == 1
result = $(esc(ex.args[1]))(vals...)
rettype = typeof(result)
is(rettype, inftypes[1]) || error("return type $rettype does not match inferred return type $(inftypes[1])")
rettype = isa(result, Type) ? Type{result} : typeof(result)
rettype == inftypes[1] || error("return type $rettype does not match inferred return type $(inftypes[1])")
result
end
end
Expand Down

0 comments on commit 64ad746

Please sign in to comment.