@@ -1900,7 +1900,7 @@ function get_testset_depth()
1900
1900
return length (testsets)
1901
1901
end
1902
1902
1903
- _args_and_call (args... ; kwargs... ) = (args[ 1 : end - 1 ] , kwargs, args[ end ] (args[ 1 : end - 1 ] . .. ; kwargs... ))
1903
+ _args_and_call (( args... , f) . .. ; kwargs... ) = (args, kwargs, f (args... ; kwargs... ))
1904
1904
_materialize_broadcasted (f, args... ) = Broadcast. materialize (Broadcast. broadcasted (f, args... ))
1905
1905
1906
1906
"""
@@ -1982,25 +1982,24 @@ function _inferred(ex, mod, allow = :(Union{}))
1982
1982
quote
1983
1983
let allow = $ (esc (allow))
1984
1984
allow isa Type || throw (ArgumentError (" @inferred requires a type as second argument" ))
1985
- $ (if any (a -> (Meta. isexpr (a, :kw ) || Meta. isexpr (a, :parameters )), ex. args)
1985
+ $ (if any (@nospecialize (a) -> (Meta. isexpr (a, :kw ) || Meta. isexpr (a, :parameters )), ex. args)
1986
1986
# Has keywords
1987
1987
args = gensym ()
1988
1988
kwargs = gensym ()
1989
1989
quote
1990
1990
$ (esc (args)), $ (esc (kwargs)), result = $ (esc (Expr (:call , _args_and_call, ex. args[2 : end ]. .. , ex. args[1 ])))
1991
- inftypes = $ (gen_call_with_extracted_types (mod, Base. return_types , :($ (ex. args[1 ])($ (args). .. ; $ (kwargs). .. ))))
1991
+ inftype = $ (gen_call_with_extracted_types (mod, Base. infer_return_type , :($ (ex. args[1 ])($ (args). .. ; $ (kwargs). .. ))))
1992
1992
end
1993
1993
else
1994
1994
# No keywords
1995
1995
quote
1996
1996
args = ($ ([esc (ex. args[i]) for i = 2 : length (ex. args)]. .. ),)
1997
1997
result = $ (esc (ex. args[1 ]))(args... )
1998
- inftypes = Base. return_types ($ (esc (ex. args[1 ])), Base. typesof (args... ))
1998
+ inftype = Base. infer_return_type ($ (esc (ex. args[1 ])), Base. typesof (args... ))
1999
1999
end
2000
2000
end )
2001
- @assert length (inftypes) == 1
2002
2001
rettype = result isa Type ? Type{result} : typeof (result)
2003
- rettype <: allow || rettype == typesplit (inftypes[ 1 ] , allow) || error (" return type $rettype does not match inferred return type $(inftypes[ 1 ]) " )
2002
+ rettype <: allow || rettype == typesplit (inftype , allow) || error (" return type $rettype does not match inferred return type $inftype " )
2004
2003
result
2005
2004
end
2006
2005
end
0 commit comments