@@ -1197,15 +1197,6 @@ static jl_method_instance_t *jl_mt_assoc_by_type(jl_methtable_t *mt, jl_datatype
1197
1197
return nf ;
1198
1198
}
1199
1199
1200
- void print_func_loc (JL_STREAM * s , jl_method_t * m )
1201
- {
1202
- long lno = m -> line ;
1203
- if (lno > 0 ) {
1204
- char * fname = jl_symbol_name ((jl_sym_t * )m -> file );
1205
- jl_printf (s , " at %s:%ld" , fname , lno );
1206
- }
1207
- }
1208
-
1209
1200
struct shadowed_matches_env {
1210
1201
struct typemap_intersection_env match ;
1211
1202
jl_typemap_entry_t * newentry ;
@@ -1291,14 +1282,33 @@ static jl_value_t *check_shadowed_matches(jl_typemap_t *defs, jl_typemap_entry_t
1291
1282
return env .shadowed ;
1292
1283
}
1293
1284
1285
+ void print_func_loc (JL_STREAM * s , jl_method_t * m )
1286
+ {
1287
+ long lno = m -> line ;
1288
+ if (lno > 0 ) {
1289
+ char * fname = jl_symbol_name ((jl_sym_t * )m -> file );
1290
+ jl_printf (s , " at %s:%ld" , fname , lno );
1291
+ }
1292
+ }
1293
+
1294
+ static int is_anonfn_typename (char * name )
1295
+ {
1296
+ if (name [0 ] != '#' || name [1 ] == '#' )
1297
+ return 0 ;
1298
+ char * other = strrchr (name , '#' );
1299
+ return other > & name [1 ] && other [1 ] > '0' && other [1 ] <= '9' ;
1300
+ }
1301
+
1294
1302
static void method_overwrite (jl_typemap_entry_t * newentry , jl_method_t * oldvalue )
1295
1303
{
1296
1304
// method overwritten
1305
+ jl_method_t * method = (jl_method_t * )newentry -> func .method ;
1306
+ jl_module_t * newmod = method -> module ;
1307
+ jl_module_t * oldmod = oldvalue -> module ;
1308
+ jl_datatype_t * dt = jl_first_argument_datatype (oldvalue -> sig );
1309
+ int anon = dt && is_anonfn_typename (jl_symbol_name (dt -> name -> name ));
1297
1310
if ((jl_options .warn_overwrite == JL_OPTIONS_WARN_OVERWRITE_ON ) ||
1298
- (jl_options .incremental && jl_generating_output ())) {
1299
- jl_method_t * method = (jl_method_t * )newentry -> func .method ;
1300
- jl_module_t * newmod = method -> module ;
1301
- jl_module_t * oldmod = oldvalue -> module ;
1311
+ (jl_options .incremental && jl_generating_output ()) || anon ) {
1302
1312
JL_STREAM * s = JL_STDERR ;
1303
1313
jl_printf (s , "WARNING: Method definition " );
1304
1314
jl_static_show_func_sig (s , (jl_value_t * )newentry -> sig );
@@ -1307,7 +1317,10 @@ static void method_overwrite(jl_typemap_entry_t *newentry, jl_method_t *oldvalue
1307
1317
jl_printf (s , " overwritten" );
1308
1318
if (oldmod != newmod )
1309
1319
jl_printf (s , " in module %s" , jl_symbol_name (newmod -> name ));
1310
- print_func_loc (s , method );
1320
+ if (method -> line > 0 && method -> line == oldvalue -> line && method -> file == oldvalue -> file )
1321
+ jl_printf (s , anon ? " on the same line" : " on the same line (check for duplicate calls to `include`)" );
1322
+ else
1323
+ print_func_loc (s , method );
1311
1324
jl_printf (s , ".\n" );
1312
1325
jl_uv_flush (s );
1313
1326
}
0 commit comments