@@ -146,7 +146,7 @@ JL_DLLEXPORT jl_method_instance_t *jl_specializations_get_linfo(jl_method_t *m,
146
146
assert (world >= m -> min_world && "typemap lookup is corrupted" );
147
147
JL_LOCK (& m -> writelock );
148
148
jl_typemap_entry_t * sf =
149
- jl_typemap_assoc_by_type (m -> specializations , ( jl_tupletype_t * ) type , NULL , /*subtype*/ 0 , /*offs*/ 0 , world , /*max_world_mask*/ 0 );
149
+ jl_typemap_assoc_by_type (m -> specializations , type , NULL , /*subtype*/ 0 , /*offs*/ 0 , world , /*max_world_mask*/ 0 );
150
150
if (sf && jl_is_method_instance (sf -> func .value )) {
151
151
jl_method_instance_t * linfo = (jl_method_instance_t * )sf -> func .value ;
152
152
assert (linfo -> min_world <= sf -> min_world && linfo -> max_world >= sf -> max_world );
@@ -177,7 +177,7 @@ JL_DLLEXPORT jl_method_instance_t *jl_specializations_get_linfo(jl_method_t *m,
177
177
return li ;
178
178
}
179
179
180
- JL_DLLEXPORT jl_value_t * jl_specializations_lookup (jl_method_t * m , jl_tupletype_t * type , size_t world )
180
+ JL_DLLEXPORT jl_value_t * jl_specializations_lookup (jl_method_t * m , jl_value_t * type , size_t world )
181
181
{
182
182
jl_typemap_entry_t * sf = jl_typemap_assoc_by_type (
183
183
m -> specializations , type , NULL , /*subtype*/ 0 , /*offs*/ 0 , world , /*max_world_mask*/ 0 );
@@ -186,7 +186,7 @@ JL_DLLEXPORT jl_value_t *jl_specializations_lookup(jl_method_t *m, jl_tupletype_
186
186
return sf -> func .value ;
187
187
}
188
188
189
- JL_DLLEXPORT jl_value_t * jl_methtable_lookup (jl_methtable_t * mt , jl_tupletype_t * type , size_t world )
189
+ JL_DLLEXPORT jl_value_t * jl_methtable_lookup (jl_methtable_t * mt , jl_value_t * type , size_t world )
190
190
{
191
191
jl_typemap_entry_t * sf = jl_typemap_assoc_by_type (
192
192
mt -> defs , type , NULL , /*subtype*/ 0 , /*offs*/ 0 , world , /*max_world_mask*/ 0 );
@@ -548,7 +548,7 @@ jl_value_t *jl_nth_slot_type(jl_value_t *sig, size_t i)
548
548
// after intersection, the argument tuple type needs to be corrected to reflect the signature match
549
549
// that occurred, if the arguments contained a Type but the signature matched on the kind
550
550
// if sharp_match is returned as false, this tt may have matched only because of bug in subtyping
551
- static jl_tupletype_t * join_tsig (jl_tupletype_t * tt , jl_tupletype_t * sig , int * sharp_match )
551
+ static jl_tupletype_t * join_tsig (jl_tupletype_t * tt , jl_value_t * sig , int * sharp_match )
552
552
{
553
553
jl_svec_t * newparams = NULL ;
554
554
JL_GC_PUSH1 (& newparams );
@@ -1070,10 +1070,10 @@ static jl_method_instance_t *jl_mt_assoc_by_type(jl_methtable_t *mt, jl_datatype
1070
1070
jl_method_instance_t * nf = NULL ;
1071
1071
JL_GC_PUSH4 (& env , & entry , & func , & sig );
1072
1072
1073
- entry = jl_typemap_assoc_by_type (mt -> defs , tt , & env , /*subtype*/ 1 , /*offs*/ 0 , world , /*max_world_mask*/ 0 );
1073
+ entry = jl_typemap_assoc_by_type (mt -> defs , ( jl_value_t * ) tt , & env , /*subtype*/ 1 , /*offs*/ 0 , world , /*max_world_mask*/ 0 );
1074
1074
if (entry != NULL ) {
1075
1075
jl_method_t * m = entry -> func .method ;
1076
- if (!jl_has_call_ambiguities (tt , m )) {
1076
+ if (!jl_has_call_ambiguities (( jl_value_t * ) tt , m )) {
1077
1077
#ifdef TRACE_COMPILE
1078
1078
if (!jl_has_free_typevars ((jl_value_t * )tt )) {
1079
1079
jl_printf (JL_STDERR , "precompile(" );
@@ -1082,7 +1082,7 @@ static jl_method_instance_t *jl_mt_assoc_by_type(jl_methtable_t *mt, jl_datatype
1082
1082
}
1083
1083
#endif
1084
1084
int sharp_match ;
1085
- sig = join_tsig (tt , ( jl_tupletype_t * ) m -> sig , & sharp_match );
1085
+ sig = join_tsig (tt , m -> sig , & sharp_match );
1086
1086
if (!mt_cache ) {
1087
1087
nf = jl_specializations_get_linfo (m , (jl_value_t * )sig , env , world );
1088
1088
}
@@ -1167,7 +1167,7 @@ static int check_ambiguous_visitor(jl_typemap_entry_t *oldentry, struct typemap_
1167
1167
// (if type-morespecific made a mistake, this also might end up finding
1168
1168
// that isect == type or isect == sig and return the original match)
1169
1169
jl_typemap_entry_t * l = jl_typemap_assoc_by_type (
1170
- map , ( jl_tupletype_t * ) isect , NULL , /*subtype*/ 0 , /*offs*/ 0 ,
1170
+ map , isect , NULL , /*subtype*/ 0 , /*offs*/ 0 ,
1171
1171
closure -> newentry -> min_world , /*max_world_mask*/ 0 );
1172
1172
if (l != NULL ) // ok, intersection is covered
1173
1173
return 1 ;
@@ -1637,15 +1637,15 @@ jl_tupletype_t *arg_type_tuple(jl_value_t **args, size_t nargs)
1637
1637
jl_method_instance_t * jl_method_lookup_by_type (jl_methtable_t * mt , jl_tupletype_t * types ,
1638
1638
int cache , int allow_exec , size_t world )
1639
1639
{
1640
- jl_typemap_entry_t * entry = jl_typemap_assoc_by_type (mt -> cache , types , NULL , /*subtype*/ 1 , jl_cachearg_offset (mt ), world , /*max_world_mask*/ 0 );
1640
+ jl_typemap_entry_t * entry = jl_typemap_assoc_by_type (mt -> cache , ( jl_value_t * ) types , NULL , /*subtype*/ 1 , jl_cachearg_offset (mt ), world , /*max_world_mask*/ 0 );
1641
1641
if (entry ) {
1642
1642
jl_method_instance_t * linfo = (jl_method_instance_t * )entry -> func .value ;
1643
1643
assert (linfo -> min_world <= entry -> min_world && linfo -> max_world >= entry -> max_world &&
1644
1644
"typemap consistency error: MethodInstance doesn't apply to full range of its entry" );
1645
1645
return linfo ;
1646
1646
}
1647
1647
JL_LOCK (& mt -> writelock );
1648
- entry = jl_typemap_assoc_by_type (mt -> cache , types , NULL , /*subtype*/ 1 , jl_cachearg_offset (mt ), world , /*max_world_mask*/ 0 );
1648
+ entry = jl_typemap_assoc_by_type (mt -> cache , ( jl_value_t * ) types , NULL , /*subtype*/ 1 , jl_cachearg_offset (mt ), world , /*max_world_mask*/ 0 );
1649
1649
if (entry ) {
1650
1650
jl_method_instance_t * linfo = (jl_method_instance_t * )entry -> func .value ;
1651
1651
assert (linfo -> min_world <= entry -> min_world && linfo -> max_world >= entry -> max_world &&
@@ -1808,12 +1808,12 @@ jl_method_instance_t *jl_get_specialization1(jl_tupletype_t *types, size_t world
1808
1808
jl_svec_t * env = (jl_svec_t * )jl_svecref (match , 1 );
1809
1809
jl_tupletype_t * ti = (jl_tupletype_t * )jl_unwrap_unionall (jl_svecref (match , 0 ));
1810
1810
jl_method_instance_t * nf = NULL ;
1811
- if (ti == types && !jl_has_call_ambiguities (types , m )) {
1811
+ if (ti == types && !jl_has_call_ambiguities (( jl_value_t * ) types , m )) {
1812
1812
jl_datatype_t * dt = jl_first_argument_datatype (jl_unwrap_unionall ((jl_value_t * )types ));
1813
1813
assert (jl_is_datatype (dt ));
1814
1814
jl_methtable_t * mt = dt -> name -> mt ;
1815
1815
int sharp_match ;
1816
- sig = join_tsig (ti , ( jl_tupletype_t * ) m -> sig , & sharp_match );
1816
+ sig = join_tsig (ti , m -> sig , & sharp_match );
1817
1817
if (sharp_match ) {
1818
1818
JL_LOCK (& mt -> writelock );
1819
1819
nf = cache_method (mt , & mt -> cache , (jl_value_t * )mt , sig , ti , m , world , env , /*allow_exec*/ 1 );
@@ -1872,7 +1872,7 @@ JL_DLLEXPORT jl_value_t *jl_get_spec_lambda(jl_tupletype_t *types, size_t world)
1872
1872
}
1873
1873
1874
1874
// see if a call to m with computed from `types` is ambiguous
1875
- JL_DLLEXPORT int jl_is_call_ambiguous (jl_tupletype_t * types , jl_method_t * m )
1875
+ JL_DLLEXPORT int jl_is_call_ambiguous (jl_value_t * types , jl_method_t * m )
1876
1876
{
1877
1877
if (m -> ambig == jl_nothing )
1878
1878
return 0 ;
@@ -1886,21 +1886,22 @@ JL_DLLEXPORT int jl_is_call_ambiguous(jl_tupletype_t *types, jl_method_t *m)
1886
1886
1887
1887
// see if a call to m with a subtype of `types` might be ambiguous
1888
1888
// if types is from a call signature (approximated by isleaftype), this is the same as jl_is_call_ambiguous above
1889
- JL_DLLEXPORT int jl_has_call_ambiguities (jl_tupletype_t * types , jl_method_t * m )
1889
+ JL_DLLEXPORT int jl_has_call_ambiguities (jl_value_t * types , jl_method_t * m )
1890
1890
{
1891
1891
if (m -> ambig == jl_nothing )
1892
1892
return 0 ;
1893
1893
for (size_t i = 0 ; i < jl_array_len (m -> ambig ); i ++ ) {
1894
1894
jl_method_t * mambig = (jl_method_t * )jl_array_ptr_ref (m -> ambig , i );
1895
- if (!jl_has_empty_intersection (( jl_value_t * ) mambig -> sig , ( jl_value_t * ) types ))
1895
+ if (!jl_has_empty_intersection (mambig -> sig , types ))
1896
1896
return 1 ;
1897
1897
}
1898
1898
return 0 ;
1899
1899
}
1900
1900
1901
1901
// add type of `f` to front of argument tuple type
1902
- jl_tupletype_t * jl_argtype_with_function (jl_function_t * f , jl_tupletype_t * types )
1902
+ jl_value_t * jl_argtype_with_function (jl_function_t * f , jl_value_t * types0 )
1903
1903
{
1904
+ jl_value_t * types = jl_unwrap_unionall (types0 );
1904
1905
size_t l = jl_nparams (types );
1905
1906
jl_value_t * tt = (jl_value_t * )jl_alloc_svec (1 + l );
1906
1907
size_t i ;
@@ -1912,8 +1913,9 @@ jl_tupletype_t *jl_argtype_with_function(jl_function_t *f, jl_tupletype_t *types
1912
1913
for (i = 0 ; i < l ; i ++ )
1913
1914
jl_svecset (tt , i + 1 , jl_tparam (types ,i ));
1914
1915
tt = (jl_value_t * )jl_apply_tuple_type ((jl_svec_t * )tt );
1916
+ tt = jl_rewrap_unionall (tt , types0 );
1915
1917
JL_GC_POP ();
1916
- return ( jl_tupletype_t * ) tt ;
1918
+ return tt ;
1917
1919
}
1918
1920
1919
1921
#ifdef JL_TRACE
@@ -2083,9 +2085,9 @@ JL_DLLEXPORT jl_value_t *jl_apply_generic(jl_value_t **args, uint32_t nargs)
2083
2085
return verify_type (res );
2084
2086
}
2085
2087
2086
- JL_DLLEXPORT jl_value_t * jl_gf_invoke_lookup (jl_datatype_t * types , size_t world )
2088
+ JL_DLLEXPORT jl_value_t * jl_gf_invoke_lookup (jl_value_t * types , size_t world )
2087
2089
{
2088
- jl_methtable_t * mt = (( jl_datatype_t * ) jl_tparam0 ( types ) )-> name -> mt ;
2090
+ jl_methtable_t * mt = jl_first_argument_datatype ( types )-> name -> mt ;
2089
2091
jl_svec_t * env = jl_emptysvec ;
2090
2092
JL_GC_PUSH1 (& env );
2091
2093
jl_typemap_entry_t * entry = jl_typemap_assoc_by_type (
@@ -2107,21 +2109,21 @@ JL_DLLEXPORT jl_value_t *jl_gf_invoke_lookup(jl_datatype_t *types, size_t world)
2107
2109
// every definition has its own private method table for this purpose.
2108
2110
//
2109
2111
// NOTE: assumes argument type is a subtype of the lookup type.
2110
- jl_value_t * jl_gf_invoke (jl_tupletype_t * types0 , jl_value_t * * args , size_t nargs )
2112
+ jl_value_t * jl_gf_invoke (jl_value_t * types0 , jl_value_t * * args , size_t nargs )
2111
2113
{
2112
2114
size_t world = jl_get_ptls_states ()-> world_age ;
2113
2115
jl_svec_t * tpenv = jl_emptysvec ;
2114
2116
jl_tupletype_t * tt = NULL ;
2115
- jl_tupletype_t * types = NULL ;
2117
+ jl_value_t * types = NULL ;
2116
2118
jl_tupletype_t * sig = NULL ;
2117
2119
JL_GC_PUSH4 (& types , & tpenv , & sig , & tt );
2118
2120
jl_value_t * gf = args [0 ];
2119
- types = ( jl_datatype_t * ) jl_argtype_with_function (gf , ( jl_tupletype_t * ) types0 );
2121
+ types = jl_argtype_with_function (gf , types0 );
2120
2122
jl_methtable_t * mt = jl_gf_mtable (gf );
2121
2123
jl_typemap_entry_t * entry = (jl_typemap_entry_t * )jl_gf_invoke_lookup (types , world );
2122
2124
2123
2125
if ((jl_value_t * )entry == jl_nothing ) {
2124
- jl_method_error_bare (gf , ( jl_value_t * ) types0 , world );
2126
+ jl_method_error_bare (gf , types0 , world );
2125
2127
// unreachable
2126
2128
}
2127
2129
@@ -2154,7 +2156,7 @@ jl_value_t *jl_gf_invoke(jl_tupletype_t *types0, jl_value_t **args, size_t nargs
2154
2156
method -> invokes .unknown = jl_nothing ;
2155
2157
2156
2158
int sharp_match ;
2157
- sig = join_tsig (tt , ( jl_tupletype_t * ) method -> sig , & sharp_match );
2159
+ sig = join_tsig (tt , method -> sig , & sharp_match );
2158
2160
mfunc = cache_method (mt , & method -> invokes , entry -> func .value , sig , tt , method , world , tpenv , 1 );
2159
2161
}
2160
2162
JL_UNLOCK (& method -> writelock );
@@ -2197,10 +2199,10 @@ static int tupletype_has_datatype(jl_tupletype_t *tt, tupletype_stack_t *stack)
2197
2199
2198
2200
JL_DLLEXPORT jl_value_t * jl_get_invoke_lambda (jl_methtable_t * mt ,
2199
2201
jl_typemap_entry_t * entry ,
2200
- jl_tupletype_t * tt ,
2202
+ jl_value_t * tt ,
2201
2203
size_t world )
2202
2204
{
2203
- if (!jl_is_leaf_type ((jl_value_t * )tt ) || tupletype_has_datatype (tt , NULL ))
2205
+ if (!jl_is_leaf_type ((jl_value_t * )tt ) || tupletype_has_datatype (( jl_tupletype_t * ) tt , NULL ))
2204
2206
return jl_nothing ;
2205
2207
2206
2208
jl_method_t * method = entry -> func .method ;
@@ -2228,7 +2230,7 @@ JL_DLLEXPORT jl_value_t *jl_get_invoke_lambda(jl_methtable_t *mt,
2228
2230
JL_GC_PUSH2 (& tpenv , & sig );
2229
2231
if (jl_is_unionall (entry -> sig )) {
2230
2232
jl_value_t * ti =
2231
- jl_type_intersection_env (( jl_value_t * ) tt , (jl_value_t * )entry -> sig , & tpenv );
2233
+ jl_type_intersection_env (tt , (jl_value_t * )entry -> sig , & tpenv );
2232
2234
assert (ti != (jl_value_t * )jl_bottom_type );
2233
2235
(void )ti ;
2234
2236
}
@@ -2237,9 +2239,9 @@ JL_DLLEXPORT jl_value_t *jl_get_invoke_lambda(jl_methtable_t *mt,
2237
2239
method -> invokes .unknown = jl_nothing ;
2238
2240
2239
2241
int sharp_match ;
2240
- sig = join_tsig (tt , (jl_tupletype_t * )method -> sig , & sharp_match );
2242
+ sig = join_tsig ((jl_tupletype_t * )tt , method -> sig , & sharp_match );
2241
2243
jl_method_instance_t * mfunc = cache_method (mt , & method -> invokes , entry -> func .value ,
2242
- sig , tt , method , world , tpenv , 1 );
2244
+ sig , ( jl_tupletype_t * ) tt , method , world , tpenv , 1 );
2243
2245
JL_GC_POP ();
2244
2246
JL_UNLOCK (& method -> writelock );
2245
2247
return (jl_value_t * )mfunc ;
0 commit comments