Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit efee9e4

Browse files
committed
replace MethodError in which()
formatting fixes
1 parent 648f74e commit efee9e4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

base/interactiveutil.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ function which(f::Callable, t::(Type...))
191191
throw(ErrorException("not a generic function, no methods available"))
192192
end
193193
ms = methods(f, t)
194-
isempty(ms) && throw(MethodError(f, t))
194+
isempty(ms) && error("no method found for the specified argument types")
195195
ms[1]
196196
end
197197

@@ -203,11 +203,11 @@ function gen_call_with_extracted_types(fcn, ex0)
203203
# keyword args not used in dispatch, so just remove them
204204
args = filter(a->!(Meta.isexpr(a, :kw) || Meta.isexpr(a, :parameters)), ex0.args)
205205
return Expr(:call, fcn, esc(args[1]),
206-
Expr(:call, :typesof, map(esc, args[2:end])...))
206+
Expr(:call, :typesof, map(esc, args[2:end])...))
207207
end
208208
if isa(ex0, Expr) && ex0.head == :call
209209
return Expr(:call, fcn, esc(ex0.args[1]),
210-
Expr(:call, :typesof, map(esc, ex0.args[2:end])...))
210+
Expr(:call, :typesof, map(esc, ex0.args[2:end])...))
211211
end
212212
ex = expand(ex0)
213213
exret = Expr(:call, :error, "expression is not a function call")
@@ -221,15 +221,15 @@ function gen_call_with_extracted_types(fcn, ex0)
221221
Expr(:call, :typesof, map(esc, ex.args[3:end])...))
222222
else
223223
exret = Expr(:call, fcn, esc(ex.args[1]),
224-
Expr(:call, :typesof, map(esc, ex.args[2:end])...))
224+
Expr(:call, :typesof, map(esc, ex.args[2:end])...))
225225
end
226226
elseif ex.head == :body
227227
a1 = ex.args[1]
228228
if isa(a1, Expr) && a1.head == :call
229229
a11 = a1.args[1]
230230
if a11 == :setindex!
231231
exret = Expr(:call, fcn, a11,
232-
Expr(:call, :typesof, map(esc, a1.args[2:end])...))
232+
Expr(:call, :typesof, map(esc, a1.args[2:end])...))
233233
end
234234
end
235235
elseif ex.head == :thunk
@@ -243,7 +243,7 @@ end
243243
for fname in [:which, :less, :edit, :code_typed, :code_lowered, :code_llvm, :code_native]
244244
@eval begin
245245
macro ($fname)(ex0)
246-
gen_call_with_extracted_types($fname, ex0)
246+
gen_call_with_extracted_types($(Expr(:quote,fname)), ex0)
247247
end
248248
end
249249
end

0 commit comments

Comments
 (0)