diff --git a/src/builtins.c b/src/builtins.c index a48a0fb84e297..cdc9ed426a11e 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -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; diff --git a/src/dump.c b/src/dump.c index 00813dba3bcb4..c5e14b00bd379 100644 --- a/src/dump.c +++ b/src/dump.c @@ -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); } } diff --git a/src/julia_internal.h b/src/julia_internal.h index 356f1d08589f8..e22529569e70a 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -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); diff --git a/src/toplevel.c b/src/toplevel.c index b08800f498f70..e6879ed226f37 100644 --- a/src/toplevel.c +++ b/src/toplevel.c @@ -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) @@ -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; @@ -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);