Skip to content

Commit b78bd0a

Browse files
committed
Fix OpaqueClosure show method
This file moved into Base.Experimental late in the PR cycle, which doesn't have Base.show imported. Just move the show methods to show.jl, since OpaqueClosure is defined in Core anyway - might as well.
1 parent aad4fec commit b78bd0a

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

base/opaque_closure.jl

-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
function show(io::IO, oc::Core.OpaqueClosure)
2-
A, R = typeof(oc).parameters
3-
show_tuple_as_call(io, Symbol(""), A; hasfirst=false)
4-
print(io, "::", R)
5-
print(io, "->◌")
6-
end
7-
8-
function show(io::IO, ::MIME"text/plain", oc::Core.OpaqueClosure{A, R}) where {A, R}
9-
show(io, oc)
10-
end
11-
121
"""
132
@opaque (args...) -> body
143

base/show.jl

+12
Original file line numberDiff line numberDiff line change
@@ -2848,3 +2848,15 @@ end
28482848
bitshow(B::BitArray) = bitshow(stdout, B)
28492849

28502850
bitstring(B::BitArray) = sprint(bitshow, B)
2851+
2852+
# printing OpaqueClosure
2853+
function show(io::IO, oc::Core.OpaqueClosure)
2854+
A, R = typeof(oc).parameters
2855+
show_tuple_as_call(io, Symbol(""), A; hasfirst=false)
2856+
print(io, "::", R)
2857+
print(io, "->◌")
2858+
end
2859+
2860+
function show(io::IO, ::MIME"text/plain", oc::Core.OpaqueClosure{A, R}) where {A, R}
2861+
show(io, oc)
2862+
end

test/opaque_closure.jl

+3
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,6 @@ end
150150
mk_va_opaque() = @opaque (x...)->x
151151
@test mk_va_opaque()(1) == (1,)
152152
@test mk_va_opaque()(1,2) == (1,2)
153+
154+
# OpaqueClosure show method
155+
@test repr(@opaque x->1) == "(::Any)::Any->◌"

0 commit comments

Comments
 (0)