Skip to content

Commit

Permalink
incremental deserializer: extract mt correctly
Browse files Browse the repository at this point in the history
fix #16905
  • Loading branch information
vtjnash committed Jun 13, 2016
1 parent 8aa1d5c commit 1045147
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ JL_DLLEXPORT size_t jl_static_show(JL_STREAM *out, jl_value_t *v)

JL_DLLEXPORT size_t jl_static_show_func_sig(JL_STREAM *s, jl_value_t *type)
{
jl_value_t *ftype = jl_first_argument_datatype(type);
jl_value_t *ftype = (jl_value_t*)jl_first_argument_datatype(type);
if (ftype == NULL)
return jl_static_show(s, type);
size_t n = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1691,8 +1691,8 @@ static void jl_deserialize_lambdas_from_mod(ios_t *s)
if (meth == NULL)
return;
jl_tupletype_t *simpletype = (jl_tupletype_t*)jl_deserialize_value(s, NULL);
jl_datatype_t *gf = (jl_datatype_t*)jl_tparam0(meth->sig);
assert(jl_is_datatype(gf));
jl_datatype_t *gf = jl_first_argument_datatype((jl_value_t*)meth->sig);
assert(jl_is_datatype(gf) && gf->name->mt);
jl_method_table_insert(gf->name->mt, meth, simpletype);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ jl_lambda_info_t *jl_method_lookup_by_type(jl_methtable_t *mt, jl_tupletype_t *t
jl_lambda_info_t *jl_method_lookup(jl_methtable_t *mt, jl_value_t **args, size_t nargs, int cache);
jl_value_t *jl_gf_invoke(jl_tupletype_t *types, jl_value_t **args, size_t nargs);

jl_value_t *jl_first_argument_datatype(jl_value_t *argtypes);
jl_datatype_t *jl_first_argument_datatype(jl_value_t *argtypes);
int jl_has_intrinsics(jl_lambda_info_t *li, jl_value_t *v, jl_module_t *m);

jl_value_t *jl_nth_slot_type(jl_tupletype_t *sig, size_t i);
Expand Down
18 changes: 9 additions & 9 deletions src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ JL_DLLEXPORT jl_value_t *jl_generic_function_def(jl_sym_t *name, jl_value_t **bp
return gf;
}

jl_datatype_t *first_arg_datatype(jl_value_t *a, int got_tuple1)
static jl_datatype_t *first_arg_datatype(jl_value_t *a, int got_tuple1)
{
if (jl_is_datatype(a)) {
if (got_tuple1)
Expand Down Expand Up @@ -696,9 +696,9 @@ jl_datatype_t *first_arg_datatype(jl_value_t *a, int got_tuple1)
}

// get DataType of first tuple element, or NULL if cannot be determined
jl_value_t *jl_first_argument_datatype(jl_value_t *argtypes)
jl_datatype_t *jl_first_argument_datatype(jl_value_t *argtypes)
{
return (jl_value_t*)first_arg_datatype(argtypes, 0);
return first_arg_datatype(argtypes, 0);
}

extern tracer_cb jl_newmeth_tracer;
Expand Down Expand Up @@ -726,17 +726,17 @@ JL_DLLEXPORT void jl_method_def(jl_svec_t *argdata, jl_lambda_info_t *f, jl_valu

if (jl_is_tuple_type(argtypes) && jl_nparams(argtypes) > 0 && !jl_is_type(jl_tparam0(argtypes)))
jl_error("function type in method definition is not a type");
jl_value_t *ftype = jl_first_argument_datatype((jl_value_t*)argtypes);
jl_datatype_t *ftype = jl_first_argument_datatype((jl_value_t*)argtypes);
if (ftype == NULL ||
!(jl_is_type_type(ftype) ||
!(jl_is_type_type((jl_value_t*)ftype) ||
(jl_is_datatype(ftype) &&
(!((jl_datatype_t*)ftype)->abstract || jl_is_leaf_type(ftype)) &&
((jl_datatype_t*)ftype)->name->mt != NULL)))
(!ftype->abstract || jl_is_leaf_type((jl_value_t*)ftype)) &&
ftype->name->mt != NULL)))
jl_error("cannot add methods to an abstract type");
mt = ((jl_datatype_t*)ftype)->name->mt;
mt = ftype->name->mt;
name = mt->name;

if (jl_subtype(ftype, (jl_value_t*)jl_builtin_type, 0))
if (jl_subtype((jl_value_t*)ftype, (jl_value_t*)jl_builtin_type, 0))
jl_error("cannot add methods to a builtin function");

m = jl_new_method(f, name, argtypes, tvars, isstaged == jl_true);
Expand Down

0 comments on commit 1045147

Please sign in to comment.