Skip to content

Commit efa7e4e

Browse files
authored
improve inferrabilities in Test module (#39761)
* improve inferrabilities in `Test` module
1 parent 22f84e7 commit efa7e4e

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

base/show.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2298,7 +2298,7 @@ end
22982298
function print_type_stacktrace(io, type; color=:normal)
22992299
str = sprint(show, type, context=io)
23002300
i = findfirst('{', str)
2301-
if isnothing(i) || !get(io, :backtrace, false)::Bool
2301+
if i === nothing || !get(io, :backtrace, false)::Bool
23022302
printstyled(io, str; color=color)
23032303
else
23042304
printstyled(io, str[1:prevind(str,i)]; color=color)

base/stacktraces.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,9 @@ function show(io::IO, frame::StackFrame)
269269
end
270270

271271
function Base.parentmodule(frame::StackFrame)
272-
if frame.linfo isa MethodInstance
273-
def = frame.linfo.def
272+
linfo = frame.linfo
273+
if linfo isa MethodInstance
274+
def = linfo.def
274275
if def isa Module
275276
return def
276277
else

stdlib/Test/src/Test.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function scrub_backtrace(bt)
6060
end
6161

6262
function scrub_exc_stack(stack)
63-
return Any[ (x[1], scrub_backtrace(x[2])) for x in stack ]
63+
return Any[ (x[1], scrub_backtrace(x[2]::Vector{Union{Ptr{Nothing},Base.InterpreterIP}})) for x in stack ]
6464
end
6565

6666
# define most of the test infrastructure without type specialization
@@ -259,7 +259,7 @@ end
259259

260260
struct Threw <: ExecutionResult
261261
exception
262-
backtrace
262+
backtrace::Union{Nothing,Vector{Any}}
263263
source::LineNumberNode
264264
end
265265

@@ -551,7 +551,7 @@ function do_test(result::ExecutionResult, orig_expr)
551551
# The predicate couldn't be evaluated without throwing an
552552
# exception, so that is an Error and not a Fail
553553
@assert isa(result, Threw)
554-
testres = Error(:test_error, orig_expr, result.exception, result.backtrace, result.source)
554+
testres = Error(:test_error, orig_expr, result.exception, result.backtrace::Vector{Any}, result.source)
555555
end
556556
isa(testres, Pass) || ccall(:jl_breakpoint, Cvoid, (Any,), result)
557557
record(get_testset(), testres)

0 commit comments

Comments
 (0)