diff --git a/base/inference.jl b/base/inference.jl index 3ead1f0aab10c..ace9205e9ef6b 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -706,26 +706,20 @@ function invoke_tfunc(f, types, argtype) if is(argtype,Bottom) return Bottom end - applicable = _methods(f, types, -1) - if isempty(applicable) + meth = ccall(:jl_gf_invoke_lookup, Any, (Any, Any), f, types) + if is(meth, nothing) return Any end - for (m::SimpleVector) in applicable - local linfo - try - linfo = func_for_method(m[3],types,m[2]) - catch - return Any - end - if typeseq(m[1],types) - tvars = m[2][1:2:end] - (ti, env) = ccall(:jl_match_method, Any, (Any,Any,Any), - argtype, m[1], tvars)::SimpleVector - (_tree,rt) = typeinf(linfo, ti, env, linfo) - return rt - end + (ti, env) = ccall(:jl_match_method, Any, (Any, Any, Any), + argtype, meth.sig, meth.tvars)::SimpleVector + local linfo + try + linfo = func_for_method(meth, types, env) + catch + return Any end - return Any + (_tree, rt) = typeinf(linfo, ti, env, linfo) + return rt end # `types` is an array of inferred types for expressions in `args`.