Skip to content

Commit

Permalink
fix #11982
Browse files Browse the repository at this point in the history
disable widening entirely when specializing staged functions
  • Loading branch information
JeffBezanson committed Jul 2, 2015
1 parent 95bf20d commit afc6308
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ static jl_function_t *cache_method(jl_methtable_t *mt, jl_tupletype_t *type,
for (i=0; i < np; i++) {
jl_value_t *elt = jl_tparam(type,i);
jl_value_t *decl_i = jl_nth_slot_type(decl,i);
if (jl_is_type_type(elt) && jl_is_tuple_type(jl_tparam0(elt)) &&
if (!isstaged && jl_is_type_type(elt) && jl_is_tuple_type(jl_tparam0(elt)) &&
!(jl_subtype(decl_i, (jl_value_t*)jl_type_type, 0) && !is_kind(decl_i))) {
jl_methlist_t *curr = mt->defs;
int ok=1;
Expand Down Expand Up @@ -520,7 +520,7 @@ static jl_function_t *cache_method(jl_methtable_t *mt, jl_tupletype_t *type,
set_to_any = 1;
}
}
if (set_to_any) {
if (set_to_any || isstaged) {
}
else if (jl_is_type_type(elt) && jl_is_type_type(jl_tparam0(elt)) &&
// give up on specializing static parameters for Type{Type{Type{...}}}
Expand Down
7 changes: 7 additions & 0 deletions test/staged.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,10 @@ f10502() = ()
# One-line @generated functions
@generated oneliner(x,y) = :($x, x, $y, y)
@test oneliner(1, 2.) == (Int, 1, Float64, 2.)

# issue #11982
@generated function f11982(T)
string(T.parameters[1])
end
@test f11982(Float32) == "Float32"
@test f11982(Int32) == "Int32"

0 comments on commit afc6308

Please sign in to comment.