Skip to content

Commit 98f8c23

Browse files
committed
Get rid of all invalidations
1 parent 09e344a commit 98f8c23

File tree

6 files changed

+5
-35
lines changed

6 files changed

+5
-35
lines changed

base/logging.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ function handle_message(logger::SimpleLogger, level::LogLevel, message, _module,
677677
end
678678
iob = IOContext(buf, stream)
679679
levelstr = level == Warn ? "Warning" : string(level)
680-
msglines = eachsplit(chomp(string(message)::String), '\n')
680+
msglines = eachsplit(chomp(convert(String, string(message))::String), '\n')
681681
msg1, rest = Iterators.peel(msglines)
682682
println(iob, "", levelstr, ": ", msg1)
683683
for msg in rest

base/show.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2006,7 +2006,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
20062006
na = length(func_args)
20072007
if (na == 2 || (na > 2 && isa(func, Symbol) && func in (:+, :++, :*)) || (na == 3 && func === :(:))) &&
20082008
all(a -> !isa(a, Expr) || a.head !== :..., func_args)
2009-
sep = func === :(:) ? "$func" : " " * string(func)::String * " " # if func::Any, avoid string interpolation (invalidation)
2009+
sep = func === :(:) ? "$func" : " " * convert(String, string(func))::String * " " # if func::Any, avoid string interpolation (invalidation)
20102010

20112011
if func_prec <= prec
20122012
show_enclosed_list(io, '(', func_args, sep, ')', indent, func_prec, quote_level, true)

base/strings/basic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ Symbol(s::AbstractString) = Symbol(String(s))
229229
Symbol(x...) = Symbol(string(x...))
230230

231231
convert(::Type{T}, s::T) where {T<:AbstractString} = s
232-
convert(::Type{T}, s::AbstractString) where {T<:AbstractString} = T(s)::T
232+
convert(::Type{T}, s::AbstractString) where {T<:AbstractString} = T(s)
233233

234234
## summary ##
235235

stdlib/Logging/src/ConsoleLogger.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function handle_message(logger::ConsoleLogger, level::LogLevel, message, _module
116116

117117
# Generate a text representation of the message and all key value pairs,
118118
# split into lines.
119-
msglines = [(indent=0, msg=l) for l in split(chomp(string(message)::String), '\n')]
119+
msglines = [(indent=0, msg=l) for l in split(chomp(convert(String, string(message))::String), '\n')]
120120
stream::IO = logger.stream
121121
if !(isopen(stream)::Bool)
122122
stream = stderr

stdlib/REPL/src/REPL.jl

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -566,33 +566,6 @@ mutable struct REPLHistoryProvider <: HistoryProvider
566566
last_mode::Union{Nothing,Prompt}
567567
mode_mapping::Dict{Symbol,Prompt}
568568
modes::Vector{Symbol}
569-
570-
# Explicit constructor to avoid `convert` invalidations.
571-
function REPLHistoryProvider(
572-
history,
573-
file_path::AbstractString,
574-
history_file,
575-
start_idx,
576-
cur_idx,
577-
last_idx,
578-
last_buffer,
579-
last_mode,
580-
mode_mapping,
581-
modes
582-
)
583-
new(
584-
history,
585-
file_path,
586-
history_file,
587-
start_idx,
588-
cur_idx,
589-
last_idx,
590-
last_buffer,
591-
last_mode,
592-
mode_mapping,
593-
modes
594-
)
595-
end
596569
end
597570
REPLHistoryProvider(mode_mapping::Dict{Symbol}) =
598571
REPLHistoryProvider(String[], "", nothing, 0, 0, -1, IOBuffer(),

test/invalidations.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ isdefined(Main, :MethodInvalidations) || @eval Main include(joinpath($(BASE_TEST
44
import Base
55

66
using .Main.MethodInvalidations
7-
using REPL: REPL
87

98
f(x) = x
109
g(x) = f(x)
@@ -18,6 +17,4 @@ invs = @method_invalidations f(x::Int) = 2x
1817
struct X end
1918

2019
invs = @method_invalidations Base.convert(::Type{String}, ::X) = X()
21-
@test !invalidated(invs, Base.show_unquoted)
22-
@test !invalidated(invs, REPL.REPLHistoryProvider)
23-
@test !invalidated(invs, Base.CoreLogging.handle_message)
20+
@test length(uinvalidated(invs)) == 0

0 commit comments

Comments
 (0)