11# This file is a part of Julia. License is MIT: https://julialang.org/license
22
3- function is_argtype_match (@nospecialize (given_argtype),
3+ @latticeop args function is_argtype_match (@nospecialize (given_argtype),
44 @nospecialize (cache_argtype),
55 overridden_by_const:: Bool )
66 if is_forwardable_argtype (given_argtype)
@@ -26,7 +26,7 @@ function matching_cache_argtypes(
2626 @assert isa (linfo. def, Method) # ensure the next line works
2727 nargs:: Int = linfo. def. nargs
2828 cache_argtypes, overridden_by_const = matching_cache_argtypes (linfo, nothing , va_override)
29- given_argtypes = Vector {Any } (undef, length (argtypes))
29+ given_argtypes = Vector {AbstractLattice } (undef, length (argtypes))
3030 local condargs = nothing
3131 for i in 1 : length (argtypes)
3232 argtype = argtypes[i]
@@ -42,7 +42,7 @@ function matching_cache_argtypes(
4242 if vtype === Bottom && elsetype === Bottom
4343 # we accidentally proved this method match is impossible
4444 # TODO bail out here immediately rather than just propagating Bottom ?
45- given_argtypes[i] = Bottom
45+ given_argtypes[i] = ⊥
4646 else
4747 if condargs === nothing
4848 condargs = Tuple{Int,Int}[]
@@ -56,18 +56,18 @@ function matching_cache_argtypes(
5656 given_argtypes[i] = widenconditional (argtype)
5757 end
5858 isva = va_override || linfo. def. isva
59- if isva || isvarargtype (given_argtypes[end ])
59+ if isva || isvarargtype (unwraptype ( given_argtypes[end ]) )
6060 isva_given_argtypes = Vector {Any} (undef, nargs)
6161 for i = 1 : (nargs - isva)
6262 isva_given_argtypes[i] = argtype_by_index (given_argtypes, i)
6363 end
6464 if isva
65- if length (given_argtypes) < nargs && isvarargtype (given_argtypes[end ])
65+ if length (given_argtypes) < nargs && isvarargtype (unwraptype ( given_argtypes[end ]) )
6666 last = length (given_argtypes)
6767 else
6868 last = nargs
6969 end
70- isva_given_argtypes[nargs] = tuple_tfunc (given_argtypes[last: end ])
70+ isva_given_argtypes[nargs] = TypeLattice ( tuple_tfunc (anymap (unwraptype, given_argtypes[last: end ])) )
7171 # invalidate `Conditional` imposed on varargs
7272 if condargs != = nothing
7373 for (slotid, i) in condargs
@@ -101,7 +101,7 @@ function most_general_argtypes(method::Union{Method, Nothing}, @nospecialize(spe
101101 # For opaque closure, the closure environment is processed elsewhere
102102 nargs -= 1
103103 end
104- cache_argtypes = Vector {Any } (undef, nargs)
104+ cache_argtypes = Vector {AbstractLattice } (undef, nargs)
105105 # First, if we're dealing with a varargs method, then we set the last element of `args`
106106 # to the appropriate `Tuple` type or `PartialStruct` instance.
107107 if ! toplevel && isva
@@ -140,7 +140,7 @@ function most_general_argtypes(method::Union{Method, Nothing}, @nospecialize(spe
140140 vargtype = tuple_tfunc (vargtype_elements)
141141 end
142142 end
143- cache_argtypes[nargs] = vargtype
143+ cache_argtypes[nargs] = TypeLattice ( vargtype)
144144 nargs -= 1
145145 end
146146 # Now, we propagate type info from `linfo_argtypes` into `cache_argtypes`, improving some
@@ -168,10 +168,10 @@ function most_general_argtypes(method::Union{Method, Nothing}, @nospecialize(spe
168168 atyp = elim_free_typevars (rewrap_unionall (atyp, specTypes))
169169 end
170170 i == n && (lastatype = atyp)
171- cache_argtypes[i] = atyp
171+ cache_argtypes[i] = TypeLattice ( atyp)
172172 end
173173 for i = (tail_index + 1 ): nargs
174- cache_argtypes[i] = lastatype
174+ cache_argtypes[i] = TypeLattice ( lastatype)
175175 end
176176 else
177177 @assert nargs == 0 " invalid specialization of method" # wrong number of arguments
@@ -199,7 +199,7 @@ function matching_cache_argtypes(linfo::MethodInstance, ::Nothing, va_override::
199199 return cache_argtypes, falses (length (cache_argtypes))
200200end
201201
202- function cache_lookup (linfo:: MethodInstance , given_argtypes:: Vector{Any } , cache:: Vector{InferenceResult} )
202+ function cache_lookup (linfo:: MethodInstance , given_argtypes:: Vector{AbstractLattice } , cache:: Vector{InferenceResult} )
203203 method = linfo. def:: Method
204204 nargs:: Int = method. nargs
205205 method. isva && (nargs -= 1 )
@@ -218,7 +218,7 @@ function cache_lookup(linfo::MethodInstance, given_argtypes::Vector{Any}, cache:
218218 end
219219 end
220220 if method. isva && cache_match
221- cache_match = is_argtype_match (tuple_tfunc (given_argtypes[(nargs + 1 ): end ]),
221+ cache_match = is_argtype_match (TypeLattice ( tuple_tfunc (anymap (unwraptype, given_argtypes[(nargs + 1 ): end ])) ),
222222 cache_argtypes[end ],
223223 cache_overridden_by_const[end ])
224224 end
0 commit comments