From 80b003254666f2ee20c5d57613d0d62b14b2c61b Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sun, 17 May 2015 15:56:22 -0500 Subject: [PATCH] Don't wrap V<:Vararg in TypeVar(:_, V) --- base/inference.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/base/inference.jl b/base/inference.jl index 68a335ec9c0d7..650b675db1b23 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -174,7 +174,7 @@ const typeof_tfunc = function (t) Type{typeof(t)} end elseif isa(t,DataType) - if isleaftype(t) + if isleaftype(t) || isvarargtype(t) Type{t} else Type{TypeVar(:_,t)} @@ -222,7 +222,7 @@ function limit_type_depth(t::ANY, d::Int, cov::Bool, vars) else return t end - if inexact + if inexact && !isvarargtype(R) R = TypeVar(:_,R) push!(vars, R) end @@ -319,7 +319,7 @@ const fieldtype_tfunc = function (A, s, name) if is(t,Bottom) return t end - Type{exact || isleaftype(t) || isa(t,TypeVar) ? t : TypeVar(:_, t)} + Type{exact || isleaftype(t) || isa(t,TypeVar) || isvarargtype(t) ? t : TypeVar(:_, t)} end t_func[fieldtype] = (2, 2, fieldtype_tfunc) t_func[Box] = (1, 1, (a,)->Box) @@ -423,7 +423,7 @@ const apply_type_tfunc = function (A, args...) if type_too_complex(appl,0) return Type{TypeVar(:_,headtype)} end - uncertain && !isa(appl,TypeVar) ? Type{TypeVar(:_,appl)} : Type{appl} + uncertain && !(isa(appl,TypeVar) || isvarargtype(appl)) ? Type{TypeVar(:_,appl)} : Type{appl} end t_func[apply_type] = (1, Inf, apply_type_tfunc) @@ -972,7 +972,7 @@ function abstract_eval(e::ANY, vtypes, sv::StaticVarInfo) # abstract types yield Type{<:T} instead of Type{T}. # this doesn't really model the situation perfectly, but # "isleaftype(inference_stack.types)" should be good enough. - if isa(t,TypeVar) + if isa(t,TypeVar) || isvarargtype(t) t = Type{t} else t = Type{TypeVar(:_,t)}