diff --git a/base/Base.jl b/base/Base.jl index c39b08b13539b..0595cd4674da6 100644 --- a/base/Base.jl +++ b/base/Base.jl @@ -30,7 +30,7 @@ setproperty!(x::Type, f::Symbol, v) = setfield!(x, f, v) getproperty(x::Tuple, f::Int) = getfield(x, f) setproperty!(x::Tuple, f::Int, v) = setfield!(x, f, v) # to get a decent error -getproperty(Core.@nospecialize(x), f::Symbol) = getfield(x, f) +getproperty(x, f::Symbol) = getfield(x, f) setproperty!(x, f::Symbol, v) = setfield!(x, f, convert(fieldtype(typeof(x), f), v)) include("coreio.jl") diff --git a/base/compiler/tfuncs.jl b/base/compiler/tfuncs.jl index ace71b4004860..d91c4e69883d1 100644 --- a/base/compiler/tfuncs.jl +++ b/base/compiler/tfuncs.jl @@ -79,7 +79,9 @@ function instanceof_tfunc(@nospecialize(t)) t′ = unwrap_unionall(t) t′′, isexact = instanceof_tfunc(t′) tr = rewrap_unionall(t′′, t) - if t′′ isa DataType && !has_free_typevars(tr) + # Note: adding the <:Tuple upper bound in NamedTuple was part of the load time + # regression in #33615. + if t′′ isa DataType && !has_free_typevars(tr) && t′′.name !== NamedTuple_typename # a real instance must be within the declared bounds of the type, # so we can intersect with the original wrapper. tr = typeintersect(tr, t′′.name.wrapper) diff --git a/base/essentials.jl b/base/essentials.jl index 8a9ca0d2bc325..36887ea27c06a 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -166,7 +166,7 @@ true function convert end convert(::Type{Union{}}, x) = throw(MethodError(convert, (Union{}, x))) -convert(::Type{Any}, @nospecialize(x)) = x +convert(::Type{Any}, x) = x convert(::Type{T}, x::T) where {T} = x convert(::Type{Type}, x::Type) = x # the ssair optimizer is strongly dependent on this method existing to avoid over-specialization # in the absence of inlining-enabled diff --git a/base/linked_list.jl b/base/linked_list.jl index 195d2d02d61f1..beceb24a27f40 100644 --- a/base/linked_list.jl +++ b/base/linked_list.jl @@ -100,7 +100,7 @@ function list_deletefirst!(q::InvasiveLinkedList{T}, val::T) where T head_next = head.next while head_next !== val head = head_next - head_next = head.next + head_next = head.next::Union{T, Nothing} end if q.tail::T === val head.next = nothing diff --git a/base/promotion.jl b/base/promotion.jl index e5188755a3244..6436ee3982dcd 100644 --- a/base/promotion.jl +++ b/base/promotion.jl @@ -104,7 +104,9 @@ function typejoin(@nospecialize(a), @nospecialize(b)) if ai === bi || (isa(ai,Type) && isa(bi,Type) && ai <: bi && bi <: ai) aprimary = aprimary{ai} else - pushfirst!(vars, aprimary.var) + # pushfirst!(vars, aprimary.var) + _growbeg!(vars, 1) + arrayset(false, vars, aprimary.var, 1) aprimary = aprimary.body end end diff --git a/base/strings/io.jl b/base/strings/io.jl index 3d4f8139a8425..72379da01de91 100644 --- a/base/strings/io.jl +++ b/base/strings/io.jl @@ -107,11 +107,22 @@ function sprint(f::Function, args...; context=nothing, sizehint::Integer=0) String(resize!(s.data, s.size)) end -tostr_sizehint(x) = 8 -tostr_sizehint(x::AbstractString) = lastindex(x) -tostr_sizehint(x::Union{String,SubString{String}}) = sizeof(x) -tostr_sizehint(x::Float64) = 20 -tostr_sizehint(x::Float32) = 12 +# CategoricalArrays extends this +function tostr_sizehint end + +function _str_sizehint(x) + if x isa Float64 + return 20 + elseif x isa Float32 + return 12 + elseif x isa String || x isa SubString{String} + return sizeof(x) + elseif x isa Char + return ncodeunits(x) + else + return 8 + end +end function print_to_string(xs...) if isempty(xs) @@ -119,7 +130,7 @@ function print_to_string(xs...) end siz::Int = 0 for x in xs - siz += tostr_sizehint(x) + siz += _str_sizehint(x) end # specialized for performance reasons s = IOBuffer(sizehint=siz) @@ -135,7 +146,7 @@ function string_with_env(env, xs...) end siz::Int = 0 for x in xs - siz += tostr_sizehint(x) + siz += _str_sizehint(x) end # specialized for performance reasons s = IOBuffer(sizehint=siz) diff --git a/base/task.jl b/base/task.jl index 1814f042d7475..bfa21949e8670 100644 --- a/base/task.jl +++ b/base/task.jl @@ -545,10 +545,10 @@ function schedule(t::Task, @nospecialize(arg); error=false) t.state === :runnable || Base.error("schedule: Task not runnable") if error t.queue === nothing || Base.list_deletefirst!(t.queue, t) - t.exception = arg + setfield!(t, :exception, arg) else t.queue === nothing || Base.error("schedule: Task not runnable") - t.result = arg + setfield!(t, :result, arg) end enq_work(t) return t diff --git a/base/util.jl b/base/util.jl index fdb8a688cfe00..6a7ce2a49ed94 100644 --- a/base/util.jl +++ b/base/util.jl @@ -304,7 +304,7 @@ end ## printing with color ## -const text_colors = AnyDict( +const text_colors = Dict{Union{Symbol,Int},String}( :black => "\033[30m", :red => "\033[31m", :green => "\033[32m", @@ -334,7 +334,7 @@ for i in 0:255 text_colors[i] = "\033[38;5;$(i)m" end -const disable_text_style = AnyDict( +const disable_text_style = Dict{Symbol,String}( :bold => "\033[22m", :underline => "\033[24m", :blink => "\033[25m", diff --git a/stdlib/Distributed/src/Distributed.jl b/stdlib/Distributed/src/Distributed.jl index 08fa8d504bf9e..dbeaf6282f920 100644 --- a/stdlib/Distributed/src/Distributed.jl +++ b/stdlib/Distributed/src/Distributed.jl @@ -10,7 +10,7 @@ import Base: getindex, wait, put!, take!, fetch, isready, push!, length, hash, ==, kill, close, isopen, showerror # imports for use -using Base: Process, Semaphore, JLOptions, AnyDict, buffer_writes, @sync_add, +using Base: Process, Semaphore, JLOptions, buffer_writes, @sync_add, VERSION_STRING, binding_module, atexit, julia_exename, julia_cmd, AsyncGenerator, acquire, release, invokelatest, shell_escape_posixly, uv_error, something, notnothing, isbuffered diff --git a/stdlib/Distributed/src/cluster.jl b/stdlib/Distributed/src/cluster.jl index ac1651b06127a..e7b3086362e67 100644 --- a/stdlib/Distributed/src/cluster.jl +++ b/stdlib/Distributed/src/cluster.jl @@ -445,7 +445,7 @@ function addprocs(manager::ClusterManager; kwargs...) end function addprocs_locked(manager::ClusterManager; kwargs...) - params = merge(default_addprocs_params(), AnyDict(kwargs)) + params = merge(default_addprocs_params(), Dict{Symbol,Any}(kwargs)) topology(Symbol(params[:topology])) if PGRP.topology !== :all_to_all @@ -510,7 +510,7 @@ function set_valid_processes(plist::Array{Int}) end end -default_addprocs_params() = AnyDict( +default_addprocs_params() = Dict{Symbol,Any}( :topology => :all_to_all, :dir => pwd(), :exename => joinpath(Sys.BINDIR, julia_exename()), diff --git a/stdlib/Distributed/src/remotecall.jl b/stdlib/Distributed/src/remotecall.jl index 4fe2e1c26d199..0c8246d2bc5a7 100644 --- a/stdlib/Distributed/src/remotecall.jl +++ b/stdlib/Distributed/src/remotecall.jl @@ -1,5 +1,7 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license +abstract type AbstractRemoteRef end + """ client_refs @@ -8,9 +10,7 @@ Tracks whether a particular `AbstractRemoteRef` The `client_refs` lock is also used to synchronize access to `.refs` and associated `clientset` state. """ -const client_refs = WeakKeyDict{Any, Nothing}() # used as a WeakKeySet - -abstract type AbstractRemoteRef end +const client_refs = WeakKeyDict{AbstractRemoteRef, Nothing}() # used as a WeakKeySet """ Future(w::Int, rrid::RRID, v::Union{Some, Nothing}=nothing)