Skip to content

Commit 1d26139

Browse files
committed
CoreLogging: prevent some Annotated*-related instability
Add some concrete `typeassert`s to increase the resistance of the sysimage to invalidation by helping inference within the method body.
1 parent cdd4ac5 commit 1d26139

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

base/logging/ConsoleLogger.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ function handle_message(logger::ConsoleLogger, level::LogLevel, message, _module
123123
# Generate a text representation of the message and all key value pairs,
124124
# split into lines. This is specialised to improve type inference,
125125
# and reduce the risk of resulting method invalidations.
126+
annotations_type = Vector{@NamedTuple{region::UnitRange{Int}, label::Symbol, value}}
126127
message = string(message)
127-
msglines = if Base._isannotated(message) && !isempty(Base.annotations(message))
128-
message = Base.AnnotatedString(String(message), Base.annotations(message))
128+
msglines = if Base._isannotated(message) && !isempty(Base.annotations(message)::annotations_type)
129+
message = Base.AnnotatedString(String(message)::String, Base.annotations(message)::annotations_type)
129130
@NamedTuple{indent::Int, msg::Union{SubString{Base.AnnotatedString{String}}, SubString{String}}}[
130131
(indent=0, msg=l) for l in split(chomp(message), '\n')]
131132
else

0 commit comments

Comments
 (0)