Skip to content

Commit

Permalink
Docsystem: unwrap nospecialize (fixes #34122)
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy authored and KristofferC committed Apr 11, 2020
1 parent b621b32 commit f6272f9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ signature(@nospecialize other) = signature!([], other)
function argtype(expr::Expr)
isexpr(expr, :(::)) && return expr.args[end]
isexpr(expr, :(...)) && return :(Vararg{$(argtype(expr.args[1]))})
if isexpr(expr, :meta) && length(expr.args) == 2
a1 = expr.args[1]
if a1 === :nospecialize || a1 === :specialize
return argtype(expr.args[2])
end
end
return argtype(expr.args[1])
end
argtype(@nospecialize other) = :Any
Expand Down
15 changes: 15 additions & 0 deletions test/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ function returntype(x::Int)::Int
x
end

# @nospecialize (issue #34122)
"`fnospecialize` for Numbers"
fnospecialize(@nospecialize(x::Number)) = 1

"`fnospecialize` for arrays"
fnospecialize(@nospecialize(x::AbstractArray)) = 2

end

let md = meta(DocsTest)[@var(DocsTest)]
Expand Down Expand Up @@ -284,6 +291,14 @@ let rt = @var(DocsTest.returntype)
@test md.order == [Tuple{Float64}, Tuple{Int}]
end

let fns = @var(DocsTest.fnospecialize)
md = meta(DocsTest)[fns]
d = md.docs[Tuple{Number}]
@test docstrings_equal(d, doc"`fnospecialize` for Numbers")
d = md.docs[Tuple{AbstractArray}]
@test docstrings_equal(d, doc"`fnospecialize` for arrays")
end

@test docstrings_equal(@doc(DocsTest.TA), doc"TA")

@test docstrings_equal(@doc(DocsTest.@mac), doc"@mac()")
Expand Down

0 comments on commit f6272f9

Please sign in to comment.