From afc63084b41f3e0f102d6c4327a69bb1368b7d3b Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 2 Jul 2015 17:21:00 -0400 Subject: [PATCH] fix #11982 disable widening entirely when specializing staged functions --- src/gf.c | 4 ++-- test/staged.jl | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gf.c b/src/gf.c index 7bd1a0a3e9d65..09b2f703edd21 100644 --- a/src/gf.c +++ b/src/gf.c @@ -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; @@ -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{...}}} diff --git a/test/staged.jl b/test/staged.jl index 695013f0faa85..81aa6ba212790 100644 --- a/test/staged.jl +++ b/test/staged.jl @@ -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"