Skip to content

Commit

Permalink
Fix several sources of invalidation
Browse files Browse the repository at this point in the history
These changes fix invalidation from the JuliaData ecosystem,
presumably mostly due to new AbstractString subtypes.
  • Loading branch information
timholy committed Feb 6, 2023
1 parent 32770a7 commit 136f18c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
12 changes: 7 additions & 5 deletions src/packagedef.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,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
Expand All @@ -333,13 +332,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)
Expand All @@ -352,8 +354,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

Expand Down Expand Up @@ -651,7 +653,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
Expand Down
9 changes: 6 additions & 3 deletions src/pkgs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 136f18c

Please sign in to comment.