Skip to content

Commit 33e6e8b

Browse files
committed
look up constructors by type name in depwarn. fixes JuliaLang#21972
1 parent 223dd50 commit 33e6e8b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

base/deprecated.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ function firstcaller(bt::Array{Ptr{Void},1}, funcsyms)
9696
end
9797
found && @goto found
9898
found = lkup.func in funcsyms
99+
# look for constructor type name
100+
if !found && !isnull(lkup.linfo)
101+
li = get(lkup.linfo)
102+
ft = ccall(:jl_first_argument_datatype, Any, (Any,), li.def.sig)
103+
if isa(ft,DataType) && ft.name === Type.body.name
104+
ft = unwrap_unionall(ft.parameters[1])
105+
found = (isa(ft,DataType) && ft.name.name in funcsyms)
106+
end
107+
end
99108
end
100109
end
101110
return StackTraces.UNKNOWN

test/misc.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,14 @@ module Foo1234
779779
foo1234(x) = x+1
780780
end
781781

782+
# issue #21972
783+
struct T21972
784+
@noinline function T21972()
785+
Base.depwarn("something", :T21972)
786+
new()
787+
end
788+
end
789+
782790
@testset "@deprecate" begin
783791
using .DeprecationTests
784792
using .Foo1234
@@ -805,6 +813,13 @@ end
805813

806814
# @test @test_warn "A{T}(x::S) where {T, S} is deprecated, use f() instead." A{Int}(1.)
807815
# @test @test_nowarn A{Int}(1.)
816+
817+
# issue #21972
818+
@noinline function f21972()
819+
T21972()
820+
end
821+
@test_warn "deprecated" f21972()
822+
@test_nowarn f21972()
808823
end
809824

810825
@testset "inline bug #18735" begin

0 commit comments

Comments
 (0)