Skip to content

Commit ad39f65

Browse files
authored
type stability fixes for Base.url (#59647)
1 parent 4ef52f5 commit ad39f65

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

base/methodshow.jl

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -401,19 +401,21 @@ function url(m::Method)
401401
if LibGit2 isa Module
402402
try
403403
d = dirname(file)
404-
return LibGit2.with(LibGit2.GitRepoExt(d)) do repo
405-
LibGit2.with(LibGit2.GitConfig(repo)) do cfg
406-
u = LibGit2.get(cfg, "remote.origin.url", "")
407-
u = (match(LibGit2.GITHUB_REGEX,u)::AbstractMatch).captures[1]
408-
commit = string(LibGit2.head_oid(repo))
409-
root = LibGit2.path(repo)
410-
if startswith(file, root) || startswith(realpath(file), root)
411-
"https://github.com/$u/tree/$commit/"*file[length(root)+1:end]*"#L$line"
412-
else
413-
fileurl(file)
404+
return let file = file
405+
LibGit2.with(LibGit2.GitRepoExt(d)) do repo
406+
LibGit2.with(LibGit2.GitConfig(repo)) do cfg
407+
u = LibGit2.get(cfg, "remote.origin.url", "")
408+
u = (match(LibGit2.GITHUB_REGEX,u)::AbstractMatch).captures[1]
409+
commit = string(LibGit2.head_oid(repo))
410+
root = LibGit2.path(repo)
411+
if startswith(file, root) || startswith(realpath(file), root)
412+
"https://github.com/$u/tree/$commit/"*file[length(root)+1:end]*"#L$line"
413+
else
414+
fileurl(file)
415+
end
414416
end
415417
end
416-
end
418+
end::String
417419
catch
418420
# oops, this was a bad idea
419421
end

test/show.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,10 @@ else
877877
@test occursin("https://github.com/JuliaLang/julia/tree/$(Base.GIT_VERSION_INFO.commit)/base/special/trig.jl#L", Base.url(which(sin, (Float64,))))
878878
end
879879

880+
@testset "method show: method url return type inference" begin
881+
@test isconcretetype(Base.infer_return_type(Base.url))
882+
end
883+
880884
# Method location correction (Revise integration)
881885
dummyloc(m::Method) = :nofile, Int32(123456789)
882886
Base.methodloc_callback[] = dummyloc

0 commit comments

Comments
 (0)