@@ -16,11 +16,6 @@ function iterate(result::MethodLookupResult, args...)
1616end
1717getindex (result:: MethodLookupResult , idx:: Int ) = getindex (result. matches, idx):: MethodMatch
1818
19- struct MethodMatchResult
20- matches:: MethodLookupResult
21- overlayed:: Bool
22- end
23-
2419"""
2520 struct InternalMethodTable <: MethodTableView
2621
@@ -55,47 +50,42 @@ Overlays another method table view with an additional local fast path cache that
5550can respond to repeated, identical queries faster than the original method table.
5651"""
5752struct CachedMethodTable{T<: MethodTableView } <: MethodTableView
58- cache:: IdDict{MethodMatchKey, Union{Nothing,MethodMatchResult }}
53+ cache:: IdDict{MethodMatchKey, Union{Nothing,MethodLookupResult }}
5954 table:: T
6055end
61- CachedMethodTable (table:: T ) where T = CachedMethodTable {T} (IdDict {MethodMatchKey, Union{Nothing,MethodMatchResult }} (), table)
56+ CachedMethodTable (table:: T ) where T = CachedMethodTable {T} (IdDict {MethodMatchKey, Union{Nothing,MethodLookupResult }} (), table)
6257
6358"""
6459 findall(sig::Type, view::MethodTableView; limit::Int=-1) ->
65- MethodMatchResult( matches::MethodLookupResult, overlayed::Bool) or nothing
60+ matches::MethodLookupResult or nothing
6661
6762Find all methods in the given method table `view` that are applicable to the given signature `sig`.
6863If no applicable methods are found, an empty result is returned.
6964If the number of applicable methods exceeded the specified `limit`, `nothing` is returned.
7065Note that the default setting `limit=-1` does not limit the number of applicable methods.
7166`overlayed` indicates if any of the matching methods comes from an overlayed method table.
7267"""
73- function findall (@nospecialize (sig:: Type ), table:: InternalMethodTable ; limit:: Int = - 1 )
74- result = _findall (sig, nothing , table. world, limit)
75- result === nothing && return nothing
76- return MethodMatchResult (result, false )
77- end
68+ findall (@nospecialize (sig:: Type ), table:: InternalMethodTable ; limit:: Int = - 1 ) =
69+ _findall (sig, nothing , table. world, limit)
7870
7971function findall (@nospecialize (sig:: Type ), table:: OverlayMethodTable ; limit:: Int = - 1 )
8072 result = _findall (sig, table. mt, table. world, limit)
8173 result === nothing && return nothing
8274 nr = length (result)
8375 if nr ≥ 1 && result[nr]. fully_covers
8476 # no need to fall back to the internal method table
85- return MethodMatchResult ( result, true )
77+ return result
8678 end
8779 # fall back to the internal method table
8880 fallback_result = _findall (sig, nothing , table. world, limit)
8981 fallback_result === nothing && return nothing
9082 # merge the fallback match results with the internal method table
91- return MethodMatchResult (
92- MethodLookupResult (
93- vcat (result. matches, fallback_result. matches),
94- WorldRange (
95- max (result. valid_worlds. min_world, fallback_result. valid_worlds. min_world),
96- min (result. valid_worlds. max_world, fallback_result. valid_worlds. max_world)),
97- result. ambig | fallback_result. ambig),
98- ! isempty (result))
83+ return MethodLookupResult (
84+ vcat (result. matches, fallback_result. matches),
85+ WorldRange (
86+ max (result. valid_worlds. min_world, fallback_result. valid_worlds. min_world),
87+ min (result. valid_worlds. max_world, fallback_result. valid_worlds. max_world)),
88+ result. ambig | fallback_result. ambig)
9989end
10090
10191function _findall (@nospecialize (sig:: Type ), mt:: Union{Nothing,MethodTable} , world:: UInt , limit:: Int )
@@ -138,21 +128,19 @@ In both cases `nothing` is returned.
138128
139129`overlayed` indicates if any of the matching methods comes from an overlayed method table.
140130"""
141- function findsup (@nospecialize (sig:: Type ), table:: InternalMethodTable )
142- return (_findsup (sig, nothing , table. world)... , false )
143- end
131+ findsup (@nospecialize (sig:: Type ), table:: InternalMethodTable ) =
132+ _findsup (sig, nothing , table. world)
144133
145134function findsup (@nospecialize (sig:: Type ), table:: OverlayMethodTable )
146135 match, valid_worlds = _findsup (sig, table. mt, table. world)
147- match != = nothing && return match, valid_worlds, true
136+ match != = nothing && return match, valid_worlds
148137 # fall back to the internal method table
149138 fallback_match, fallback_valid_worlds = _findsup (sig, nothing , table. world)
150139 return (
151140 fallback_match,
152141 WorldRange (
153142 max (valid_worlds. min_world, fallback_valid_worlds. min_world),
154- min (valid_worlds. max_world, fallback_valid_worlds. max_world)),
155- false )
143+ min (valid_worlds. max_world, fallback_valid_worlds. max_world)))
156144end
157145
158146function _findsup (@nospecialize (sig:: Type ), mt:: Union{Nothing,MethodTable} , world:: UInt )
166154
167155# This query is not cached
168156findsup (@nospecialize (sig:: Type ), table:: CachedMethodTable ) = findsup (sig, table. table)
169-
170- isoverlayed (:: MethodTableView ) = error (" unsatisfied MethodTableView interface" )
171- isoverlayed (:: InternalMethodTable ) = false
172- isoverlayed (:: OverlayMethodTable ) = true
173- isoverlayed (mt:: CachedMethodTable ) = isoverlayed (mt. table)
174- isoverlayed (m:: Method ) = isdefined (m, :external_mt )
175- is_nonoverlayed (m:: Method ) = ! isoverlayed (m)
0 commit comments