@@ -903,7 +903,7 @@ function make_typealiases(@nospecialize(x::Type))
903
903
end
904
904
end
905
905
906
- function show_unionaliases (io:: IO , x:: Union )
906
+ function show_unionaliases (io:: IO , x:: Union , depth :: Integer )
907
907
properx = makeproper (io, x)
908
908
aliases, applied = make_typealiases (properx)
909
909
isempty (aliases) && return false
@@ -985,7 +985,7 @@ function _show_type(io::IO, @nospecialize(x::Type), depth::Int)
985
985
show_datatype (io, x, TypeVar[], depth)
986
986
return
987
987
elseif x isa Union
988
- if get (io, :compact , true ):: Bool && show_unionaliases (io, x)
988
+ if get (io, :compact , true ):: Bool && show_unionaliases (io, x, depth )
989
989
return
990
990
end
991
991
print (io, " Union" )
@@ -2771,23 +2771,26 @@ function type_depth_limit(str::String, n::Int; maxdepth = nothing)
2771
2771
return String (take! (output))
2772
2772
end
2773
2773
2774
- function print_type_bicolor (io, @nospecialize (type); color= :normal , inner_color= :light_black , use_color:: Bool = true , depth:: Int )
2775
- if depth > max_type_depth (io)
2774
+ function print_type_bicolor (io, type; depth:: Int = 0 , kwargs... )
2775
+ depth > max_type_depth (io) && return nothing
2776
+ str = sprint (show, type, context= io)
2777
+ print_type_bicolor (io, str; depth, kwargs... )
2778
+ end
2779
+
2780
+ function print_type_bicolor (io, str:: String ; color= :normal , inner_color= :light_black , use_color:: Bool = true , depth:: Int = 0 )
2781
+ depth > max_type_depth (io) && return nothing
2782
+ i = findfirst (' {' , str)
2783
+ if ! use_color # fix #41928
2784
+ print (io, str)
2785
+ elseif i === nothing
2786
+ printstyled (io, str; color= color)
2776
2787
else
2777
- str = sprint (show, type, context= io)
2778
- i = findfirst (' {' , str)
2779
- if ! use_color # fix #41928
2780
- print (io, str)
2781
- elseif i === nothing
2782
- printstyled (io, str; color= color)
2788
+ printstyled (io, str[1 : prevind (str,i)]; color= color)
2789
+ if endswith (str, " ..." )
2790
+ printstyled (io, str[i: prevind (str,end ,3 )]; color= inner_color)
2791
+ printstyled (io, " ..." ; color= color)
2783
2792
else
2784
- printstyled (io, str[1 : prevind (str,i)]; color= color)
2785
- if endswith (str, " ..." )
2786
- printstyled (io, str[i: prevind (str,end ,3 )]; color= inner_color)
2787
- printstyled (io, " ..." ; color= color)
2788
- else
2789
- printstyled (io, str[i: end ]; color= inner_color)
2790
- end
2793
+ printstyled (io, str[i: end ]; color= inner_color)
2791
2794
end
2792
2795
end
2793
2796
end
@@ -2818,7 +2821,7 @@ function ismodulecall(ex::Expr)
2818
2821
isa (resolvebinding (ex. args[2 ]), Module)
2819
2822
end
2820
2823
2821
- function show (io:: IO , tv:: TypeVar )
2824
+ function show (io:: IO , tv:: TypeVar , depth :: Int = 0 )
2822
2825
# If we are in the `unionall_env`, the type-variable is bound
2823
2826
# and the type constraints are already printed.
2824
2827
# We don't need to print it again.
@@ -2828,7 +2831,7 @@ function show(io::IO, tv::TypeVar)
2828
2831
function show_bound (io:: IO , @nospecialize (b))
2829
2832
parens = isa (b,UnionAll) && ! print_without_params (b)
2830
2833
parens && print (io, " (" )
2831
- show (io, b)
2834
+ show (io, b, depth )
2832
2835
parens && print (io, " )" )
2833
2836
end
2834
2837
lb, ub = tv. lb, tv. ub
@@ -2852,14 +2855,14 @@ function show(io::IO, tv::TypeVar)
2852
2855
nothing
2853
2856
end
2854
2857
2855
- function show (io:: IO , vm:: Core.TypeofVararg )
2858
+ function show (io:: IO , vm:: Core.TypeofVararg , depth :: Int = 0 )
2856
2859
print (io, " Vararg" )
2857
2860
if isdefined (vm, :T )
2858
2861
print (io, " {" )
2859
- show (io, vm. T)
2862
+ show (io, vm. T, depth + 1 )
2860
2863
if isdefined (vm, :N )
2861
2864
print (io, " , " )
2862
- show (io, vm. N)
2865
+ show (io, vm. N, depth )
2863
2866
end
2864
2867
print (io, " }" )
2865
2868
end
0 commit comments