@@ -1066,10 +1066,13 @@ static jl_function_t *jl_mt_assoc_by_type(jl_methtable_t *mt, jl_datatype_t *tt,
1066
1066
func = m -> func ;
1067
1067
if (m -> isstaged )
1068
1068
func = jl_instantiate_staged (m ,tt ,env );
1069
- JL_GC_POP ();
1070
- if (! cache )
1069
+ if (! cache ) {
1070
+ JL_GC_POP ();
1071
1071
return func ;
1072
- return cache_method (mt , tt , func , m -> sig , jl_emptysvec , m -> isstaged );
1072
+ }
1073
+ jl_function_t * res = cache_method (mt , tt , func , m -> sig , jl_emptysvec , m -> isstaged );
1074
+ JL_GC_POP ();
1075
+ return res ;
1073
1076
}
1074
1077
JL_GC_POP ();
1075
1078
return jl_bottom_func ;
@@ -1383,6 +1386,15 @@ static void remove_conflicting(jl_methlist_t **pl, jl_value_t *type)
1383
1386
}
1384
1387
}
1385
1388
1389
+ static void update_max_args (jl_methtable_t * mt , jl_tupletype_t * type )
1390
+ {
1391
+ size_t na = jl_nparams (type );
1392
+ if (jl_is_va_tuple (type ))
1393
+ na -- ;
1394
+ if (na > mt -> max_args )
1395
+ mt -> max_args = na ;
1396
+ }
1397
+
1386
1398
jl_methlist_t * jl_method_table_insert (jl_methtable_t * mt , jl_tupletype_t * type ,
1387
1399
jl_function_t * method , jl_svec_t * tvars ,
1388
1400
int8_t isstaged )
@@ -1412,12 +1424,7 @@ jl_methlist_t *jl_method_table_insert(jl_methtable_t *mt, jl_tupletype_t *type,
1412
1424
}
1413
1425
}
1414
1426
}
1415
- // update max_args
1416
- size_t na = jl_nparams (type );
1417
- if (jl_is_va_tuple (type ))
1418
- na -- ;
1419
- if (na > mt -> max_args )
1420
- mt -> max_args = na ;
1427
+ update_max_args (mt , type );
1421
1428
JL_SIGATOMIC_END ();
1422
1429
return ml ;
1423
1430
}
@@ -1825,16 +1832,15 @@ jl_value_t *jl_gf_invoke(jl_function_t *gf, jl_tupletype_t *types,
1825
1832
jl_tupletype_t * newsig = NULL ;
1826
1833
jl_tupletype_t * tt = NULL ;
1827
1834
JL_GC_PUSH3 (& tpenv , & newsig , & tt );
1828
-
1835
+ tt = arg_type_tuple ( args , nargs );
1829
1836
if (m -> invokes == (void * )jl_nothing ) {
1830
1837
m -> invokes = new_method_table (mt -> name );
1831
1838
gc_wb (m , m -> invokes );
1839
+ update_max_args (m -> invokes , tt );
1832
1840
// this private method table has just this one definition
1833
1841
jl_method_list_insert (& m -> invokes -> defs ,m -> sig ,m -> func ,m -> tvars ,0 ,0 ,(jl_value_t * )m -> invokes );
1834
1842
}
1835
1843
1836
- tt = arg_type_tuple (args , nargs );
1837
-
1838
1844
newsig = m -> sig ;
1839
1845
1840
1846
if (m -> tvars != jl_emptysvec ) {
0 commit comments