Skip to content

Commit

Permalink
fix a suboptimality in the t-function for apply_type (involving tuple…
Browse files Browse the repository at this point in the history
… types)
  • Loading branch information
JeffBezanson committed Oct 7, 2013
1 parent 9f20276 commit f3f2071
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,11 @@ const apply_type_tfunc = function (A, args...)
uncertain = false
lA = length(A)
for i=2:max(lA,length(args))
if isType(args[i])
tparams = tuple(tparams..., args[i].parameters[1])
ai = args[i]
if isType(ai)
tparams = tuple(tparams..., ai.parameters[1])
elseif isa(ai,Tuple) && all(isType,ai)
tparams = tuple(tparams..., map(t->t.parameters[1], ai))
elseif i<=lA && isa(A[i],Int)
tparams = tuple(tparams..., A[i])
else
Expand Down

1 comment on commit f3f2071

@Keno
Copy link
Member

@Keno Keno commented on f3f2071 Oct 10, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Speaking of the t-func on apply_type. Any chance we can do better on things like this:

julia> foo() = MathConst{:a}(2)
foo (generic function with 1 method)

julia> code_typed(foo,())
1-element Array{Any,1}:
 :($(Expr(:lambda, {}, {{},{},{}}, quote  # none, line 1:
        return top(apply_type)(MathConst,:a)::Type{_<:MathConst{sym}}(2)::MathConst{sym}
    end)))

It seems to me like we should be able to infer that the result is of type MathConst{:a}.

Please sign in to comment.