From 9fac2e303ec1f512396f1a0ef2f5a713025ccc57 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 23 Feb 2016 13:40:46 -0500 Subject: [PATCH] limit exponent on number of calls made by `_methods` for unions --- base/reflection.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base/reflection.jl b/base/reflection.jl index 6cb18c4e027ade..b24a2c7acbca11 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -188,11 +188,15 @@ function _methods(f::ANY,t::ANY,lim) end function _methods_by_ftype(t::ANY, lim) tp = t.parameters + nu = 1 for ti in tp if isa(ti, Union) - return _methods(Any[tp...], length(tp), lim, []) + nu *= length(ti.types) end end + if 1 < nu <= 64 + return _methods(Any[tp...], length(tp), lim, []) + end return ccall(:jl_matching_methods, Any, (Any,Int32), t, lim) end function _methods(t::Array,i,lim::Integer,matching::Array{Any,1})