Skip to content

Commit

Permalink
look up constructors by type name in depwarn. fixes #21972
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jul 16, 2017
1 parent 223dd50 commit 33e6e8b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ function firstcaller(bt::Array{Ptr{Void},1}, funcsyms)
end
found && @goto found
found = lkup.func in funcsyms
# look for constructor type name
if !found && !isnull(lkup.linfo)
li = get(lkup.linfo)
ft = ccall(:jl_first_argument_datatype, Any, (Any,), li.def.sig)
if isa(ft,DataType) && ft.name === Type.body.name
ft = unwrap_unionall(ft.parameters[1])
found = (isa(ft,DataType) && ft.name.name in funcsyms)
end
end
end
end
return StackTraces.UNKNOWN
Expand Down
15 changes: 15 additions & 0 deletions test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,14 @@ module Foo1234
foo1234(x) = x+1
end

# issue #21972
struct T21972
@noinline function T21972()
Base.depwarn("something", :T21972)
new()
end
end

@testset "@deprecate" begin
using .DeprecationTests
using .Foo1234
Expand All @@ -805,6 +813,13 @@ end

# @test @test_warn "A{T}(x::S) where {T, S} is deprecated, use f() instead." A{Int}(1.)
# @test @test_nowarn A{Int}(1.)

# issue #21972
@noinline function f21972()
T21972()
end
@test_warn "deprecated" f21972()
@test_nowarn f21972()
end

@testset "inline bug #18735" begin
Expand Down

0 comments on commit 33e6e8b

Please sign in to comment.