@@ -717,6 +717,9 @@ void print_func_loc(JL_STREAM *s, jl_method_t *m)
717
717
To check this, jl_types_equal_generic needs to be more sophisticated
718
718
so (T,T) is not equivalent to (Any,Any). (TODO)
719
719
*/
720
+
721
+ int8_t issued_ambig_warn ;
722
+
720
723
static void issue_ambig_warn (jl_typemap_entry_t * m )
721
724
{
722
725
JL_STREAM * s = JL_STDERR ;
@@ -729,6 +732,7 @@ static void issue_ambig_warn(jl_typemap_entry_t *m)
729
732
print_func_loc (s , ambigm -> func .method );
730
733
jl_printf (s , "\nSee the documentation for tips on eliminating ambiguities.\n" );
731
734
m -> ambig = ambigm -> ambig = (jl_typemap_entry_t * ) jl_nothing ;
735
+ issued_ambig_warn = 1 ;
732
736
}
733
737
734
738
struct ambiguous_matches_env {
@@ -990,12 +994,13 @@ jl_lambda_info_t *jl_method_lookup(jl_methtable_t *mt, jl_value_t **args, size_t
990
994
JL_DLLEXPORT jl_value_t * jl_matching_methods (jl_tupletype_t * types , int lim );
991
995
992
996
// compile-time method lookup
993
- jl_lambda_info_t * jl_get_specialization1 (jl_tupletype_t * types )
997
+ jl_lambda_info_t * jl_get_specialization1 (jl_tupletype_t * types , int8_t * ambig )
994
998
{
995
999
assert (jl_nparams (types ) > 0 );
996
1000
if (!jl_is_leaf_type ((jl_value_t * )types ))
997
1001
return NULL ;
998
1002
assert (jl_is_datatype (jl_tparam0 (types )));
1003
+ issued_ambig_warn = 0 ;
999
1004
1000
1005
// make sure exactly 1 method matches (issue #7302).
1001
1006
int i ;
@@ -1006,6 +1011,7 @@ jl_lambda_info_t *jl_get_specialization1(jl_tupletype_t *types)
1006
1011
// to analyze them in detail.
1007
1012
if (ti == (jl_value_t * )jl_datatype_type || jl_is_tuple_type (ti )) {
1008
1013
jl_value_t * matches = jl_matching_methods (types , 1 );
1014
+ * ambig = issued_ambig_warn ;
1009
1015
if (matches == jl_false )
1010
1016
return NULL ;
1011
1017
break ;
@@ -1022,6 +1028,7 @@ jl_lambda_info_t *jl_get_specialization1(jl_tupletype_t *types)
1022
1028
} JL_CATCH {
1023
1029
goto not_found ;
1024
1030
}
1031
+ * ambig = issued_ambig_warn ;
1025
1032
if (sf == NULL || sf -> code == NULL || sf -> inInference )
1026
1033
goto not_found ;
1027
1034
if (sf -> functionObjectsDecls .functionObject == NULL ) {
@@ -1038,7 +1045,8 @@ jl_lambda_info_t *jl_get_specialization1(jl_tupletype_t *types)
1038
1045
1039
1046
JL_DLLEXPORT void jl_compile_hint (jl_tupletype_t * types )
1040
1047
{
1041
- (void )jl_get_specialization1 (types );
1048
+ int8_t ambig ;
1049
+ (void )jl_get_specialization1 (types , & ambig );
1042
1050
}
1043
1051
1044
1052
// add type of `f` to front of argument tuple type
@@ -1076,6 +1084,7 @@ static int _compile_all_tvar_union(jl_tupletype_t *methsig, jl_svec_t *tvars)
1076
1084
// and expanding the Union may give a leaf function
1077
1085
jl_tvar_t * * tvs ;
1078
1086
int tvarslen ;
1087
+ int8_t ambig ;
1079
1088
if (jl_is_typevar (tvars )) {
1080
1089
tvs = (jl_tvar_t * * )& tvars ;
1081
1090
tvarslen = 1 ;
@@ -1087,7 +1096,7 @@ static int _compile_all_tvar_union(jl_tupletype_t *methsig, jl_svec_t *tvars)
1087
1096
if (jl_is_leaf_type ((jl_value_t * )methsig )) {
1088
1097
// usually can create a specialized version of the function,
1089
1098
// if the signature is already a leaftype
1090
- jl_lambda_info_t * spec = jl_get_specialization1 (methsig );
1099
+ jl_lambda_info_t * spec = jl_get_specialization1 (methsig , & ambig );
1091
1100
if (spec )
1092
1101
return 1 ;
1093
1102
}
@@ -1120,7 +1129,7 @@ static int _compile_all_tvar_union(jl_tupletype_t *methsig, jl_svec_t *tvars)
1120
1129
goto getnext ; // signature wouldn't be callable / is invalid -- skip it
1121
1130
}
1122
1131
if (jl_is_leaf_type (sig )) {
1123
- if (jl_get_specialization1 ((jl_tupletype_t * )sig )) {
1132
+ if (jl_get_specialization1 ((jl_tupletype_t * )sig , & ambig )) {
1124
1133
if (!jl_has_typevars ((jl_value_t * )sig )) goto getnext ; // success
1125
1134
}
1126
1135
}
0 commit comments