From 80844021da1a68fcba333ac54f392cd12b35fa08 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Mon, 6 Feb 2023 08:52:00 -0600 Subject: [PATCH] Fix several sources of invalidation These changes fix invalidation from the JuliaData ecosystem, presumably mostly due to new AbstractString subtypes. --- src/packagedef.jl | 12 +++++++----- src/pkgs.jl | 9 ++++++--- src/utils.jl | 3 ++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/packagedef.jl b/src/packagedef.jl index 9a846286..8bb768c8 100644 --- a/src/packagedef.jl +++ b/src/packagedef.jl @@ -316,7 +316,6 @@ end function eval_rex(rex::RelocatableExpr, exs_sigs_old::ExprsSigs, mod::Module; mode::Symbol=:eval) return with_logger(_debug_logger) do - sigs, includes = nothing, nothing rexo = getkey(exs_sigs_old, rex, nothing) # extract the signatures and update the line info if rexo === nothing @@ -337,13 +336,16 @@ function eval_rex(rex::RelocatableExpr, exs_sigs_old::ExprsSigs, mod::Module; mo end end storedeps(deps, rex, mod) + return sigs, includes else - sigs = exs_sigs_old[rexo] + sigs, includes = exs_sigs_old[rexo], nothing # Update location info ln, lno = firstline(unwrap(rex)), firstline(unwrap(rexo)) if sigs !== nothing && !isempty(sigs) && ln != lno ln, lno = ln::LineNumberNode, lno::LineNumberNode - @debug "LineOffset" _group="Action" time=time() deltainfo=(sigs, lno=>ln) + let sigs=sigs # #15276 + @debug "LineOffset" _group="Action" time=time() deltainfo=(sigs, lno=>ln) + end for sig in sigs locdefs = CodeTracking.method_info[sig]::AbstractVector ld = map(pr->linediff(lno, pr[1]), locdefs) @@ -356,8 +358,8 @@ function eval_rex(rex::RelocatableExpr, exs_sigs_old::ExprsSigs, mod::Module; mo locdefs[idx] = (newloc(methloc, ln, lno), methdef) end end + return sigs, includes end - return sigs, includes end end @@ -655,7 +657,7 @@ function handle_deletions(pkgdata, file) end topmod = first(keys(mexsold)) fileok = file_exists(String(filep)::String) - mexsnew = fileok ? parse_source(filep, topmod) : ModuleExprsSigs(topmod) + mexsnew = fileok ? Base.invokelatest(parse_source, filep, topmod) : ModuleExprsSigs(topmod) if mexsnew !== nothing delete_missing!(mexsold, mexsnew) end diff --git a/src/pkgs.jl b/src/pkgs.jl index 74390d2e..b5cbb481 100644 --- a/src/pkgs.jl +++ b/src/pkgs.jl @@ -357,13 +357,14 @@ end function has_writable_paths(pkgdata::PkgData) dir = basedir(pkgdata) isdir(dir) || return true - haswritable = false + haswritable = Ref(false) # avoids Core.Box cd(dir) do for file in srcfiles(pkgdata) - haswritable |= iswritable(file) + isa(file, AbstractString) || continue + haswritable[] |= iswritable(file::String) end end - return haswritable + return haswritable[] end function watch_includes(mod::Module, fn::AbstractString) @@ -439,6 +440,8 @@ function watch_manifest(mfile) files = String[] mustnotify = false for file in srcfiles(pkgdata) + isa(file, AbstractString) || continue + file = file::String fi = try maybe_parse_from_cache!(pkgdata, file) catch err diff --git a/src/utils.jl b/src/utils.jl index 626474eb..0289cea6 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -27,7 +27,8 @@ end function unique_dirs(iter) udirs = Set{String}() for file in iter - dir, basename = splitdir(file) + isa(file, AbstractString) || continue + dir, basename = splitdir(file::String) push!(udirs, dir) end return udirs