Skip to content

Commit

Permalink
fix #8861: invoke for overloaded call
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Oct 31, 2014
1 parent 68a09e0 commit ac8ba72
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,10 +892,28 @@ JL_CALLABLE(jl_f_applicable)
JL_CALLABLE(jl_f_invoke)
{
JL_NARGSV(invoke, 2);
JL_TYPECHK(invoke, function, args[0]);
if (!jl_is_gf(args[0]))
jl_error("invoke: not a generic function");
JL_TYPECHK(invoke, tuple, args[1]);
if (!jl_is_gf(args[0])) {
if (jl_is_function(args[0]))
jl_error("invoke: not a generic function");
jl_tuple_t *tup = jl_alloc_tuple_uninit(1 + jl_tuple_len(args[1]));
jl_tupleset(tup, 0, (jl_is_datatype(args[0])
? (jl_value_t*) jl_wrap_Type(args[0])
: jl_typeof(args[0])));
for(size_t i=0; i < jl_tuple_len(args[1]); i++) {
jl_tupleset(tup, i+1, jl_tupleref(args[1],i));
}
jl_value_t **newargs = (jl_value_t**) alloca(sizeof(jl_value_t*)
* (nargs + 1));
newargs[0] = (jl_value_t*) jl_module_call_func(jl_current_module);
newargs[1] = (jl_value_t*) tup;
newargs[2] = args[0];
for(uint32_t j=2; j < nargs; ++j) {
newargs[j+1] = args[j];
}
args = newargs;
nargs++;
}
jl_check_type_tuple((jl_tuple_t*)args[1], jl_gf_name(args[0]), "invoke");
if (!jl_tuple_subtype(&args[2], nargs-2, &jl_tupleref(args[1],0),
jl_tuple_len(args[1]), 1))
Expand Down
4 changes: 4 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1928,3 +1928,7 @@ type ConcreteThing{T<:FloatingPoint,N} <: AbstractThing{T,N}
end

@test typeintersect(AbstractThing{TypeVar(:T,true),2}, ConcreteThing) == ConcreteThing{TypeVar(:T,FloatingPoint),2}

# issue #8712
type Issue8712; end
@test isa(invoke(Issue8712, ()), Issue8712)

0 comments on commit ac8ba72

Please sign in to comment.