diff --git a/contrib/julia.xml b/contrib/julia.xml
index 1422b0470ba2d..491c4ee191a44 100644
--- a/contrib/julia.xml
+++ b/contrib/julia.xml
@@ -37,6 +37,7 @@
- do
- for
- function
+ - stagedfunction
- if
- immutable
- let
diff --git a/src/gf.c b/src/gf.c
index ef772c061c4d2..61a0c0cf1d273 100644
--- a/src/gf.c
+++ b/src/gf.c
@@ -454,7 +454,7 @@ static jl_value_t *ml_matches(jl_methlist_t *ml, jl_value_t *type,
static jl_function_t *cache_method(jl_methtable_t *mt, jl_tuple_t *type,
jl_function_t *method, jl_tuple_t *decl,
- jl_tuple_t *sparams)
+ jl_tuple_t *sparams, int isstaged)
{
size_t i;
int need_guard_entries = 0;
@@ -707,7 +707,7 @@ static jl_function_t *cache_method(jl_methtable_t *mt, jl_tuple_t *type,
// and the types we find should be bigger.
if (jl_tuple_len(type) > mt->max_args &&
jl_is_vararg_type(jl_tupleref(decl,jl_tuple_len(decl)-1))) {
- size_t nspec = mt->max_args + 2;
+ size_t nspec = isstaged ? jl_tuple_len(type) : mt->max_args + 2;
jl_tuple_t *limited = jl_alloc_tuple(nspec);
for(i=0; i < nspec-1; i++) {
jl_tupleset(limited, i, jl_tupleref(type, i));
@@ -1018,7 +1018,7 @@ static jl_function_t *jl_mt_assoc_by_type(jl_methtable_t *mt, jl_tuple_t *tt, in
JL_GC_POP();
if (!cache)
return func;
- return cache_method(mt, tt, func, (jl_tuple_t*)m->sig, jl_null);
+ return cache_method(mt, tt, func, (jl_tuple_t*)m->sig, jl_null, m->isstaged);
}
JL_GC_POP();
return jl_bottom_func;
@@ -1048,7 +1048,7 @@ static jl_function_t *jl_mt_assoc_by_type(jl_methtable_t *mt, jl_tuple_t *tt, in
if (!cache)
nf = func;
else
- nf = cache_method(mt, tt, func, newsig, env);
+ nf = cache_method(mt, tt, func, newsig, env, 0);
JL_GC_POP();
return nf;
}
@@ -1734,7 +1734,7 @@ jl_value_t *jl_gf_invoke(jl_function_t *gf, jl_tuple_t *types,
jl_tuple_len(tpenv)/2);
}
}
- mfunc = cache_method(m->invokes, tt, m->func, newsig, tpenv);
+ mfunc = cache_method(m->invokes, tt, m->func, newsig, tpenv, 0);
JL_GC_POP();
}