<p dir="auto">I have to admit that I don't understand the formal properties of the type system well enough to tell whether this could cause trouble, and also not clear whether this could be done in a 1.x release at all. With those caveats:</p>
<p dir="auto">The current behavior, that any subtype check with <code class="notranslate">Union{}</code> on the left hand side will return <code class="notranslate">true</code> (no matter what) was surprising to me and makes it kind of cumbersome to write code that really does what at least I want it to do when I'm checking for a subtype relationship. I've always assumed that if I write say <code class="notranslate">T &lt;: AbstractString</code>, that I really only can get a <code class="notranslate">true</code> if <code class="notranslate">T</code> is some sort of string, but it turns out that if I want that behavior I need to write <code class="notranslate">T &lt;: AbstractString &amp;&amp; T !== Union{}</code>.</p>
<p dir="auto">This came up in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="702498559" data-permission-text="Title is private" data-url="https://github.com/queryverse/TableTraits.jl/issues/21" data-hovercard-type="pull_request" data-hovercard-url="/queryverse/TableTraits.jl/pull/21/hovercard" href="https://github.com/queryverse/TableTraits.jl/pull/21">queryverse/TableTraits.jl#21</a>.</p>
<p dir="auto">I found that there is a pitfall with dispatching on custom parameterized types due to <code class="notranslate">Type{Union{}} &lt;: Type{&lt;:MyType}</code> (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="518317940" data-permission-text="Title is private" data-url="https://github.com/JuliaArrays/StaticArrays.jl/issues/685" data-hovercard-type="pull_request" data-hovercard-url="/JuliaArrays/StaticArrays.jl/pull/685/hovercard" href="https://github.com/JuliaArrays/StaticArrays.jl/pull/685">JuliaArrays/StaticArrays.jl#685</a>).  Borrowing <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/c42f/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/c42f">@c42f</a>'s <a href="https://github.com/JuliaArrays/StaticArrays.jl/pull/685#discussion_r343056774" data-hovercard-type="pull_request" data-hovercard-url="/JuliaArrays/StaticArrays.jl/pull/685/hovercard">example</a>, the problem is that:</p>
<blockquote>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; foo(::Type{T}) where {T} = &quot;generic&quot;
julia&gt; foo(::Type{&lt;:Int}) = &quot;special&quot;
julia&gt; foo(Union{})
&quot;special&quot;"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-en">foo</span>(<span class="pl-k">::</span><span class="pl-c1">Type{T}</span>) <span class="pl-k">where</span> {T} <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">"</span>generic<span class="pl-pds">"</span></span>
julia<span class="pl-k">&gt;</span> <span class="pl-en">foo</span>(<span class="pl-k">::</span><span class="pl-c1">Type{&lt;:Int}</span>) <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">"</span>special<span class="pl-pds">"</span></span>
julia<span class="pl-k">&gt;</span> <span class="pl-c1">foo</span>(Union{})
<span class="pl-s"><span class="pl-pds">"</span>special<span class="pl-pds">"</span></span></pre></div>
</blockquote>
<p dir="auto">For a concrete type like <code class="notranslate">Int</code>, the solution is to write <code class="notranslate">Type{Int}</code>.  However, it is tricky for parameterized types.  Possible workarounds are:</p>
<ol dir="auto">
<li>
<p dir="auto">Use <code class="notranslate">foo(::Type{T}) where {P, MyType{P} &lt;: T &lt;: MyType}</code>: However, this interferes with the inliner <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="518317940" data-permission-text="Title is private" data-url="https://github.com/JuliaArrays/StaticArrays.jl/issues/685" data-hovercard-type="pull_request" data-hovercard-url="/JuliaArrays/StaticArrays.jl/pull/685/hovercard?comment_id=550497302&amp;comment_type=issue_comment" href="https://github.com/JuliaArrays/StaticArrays.jl/pull/685#issuecomment-550497302">JuliaArrays/StaticArrays.jl#685 (comment)</a> possibly due to unbound type parameters (see also <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="499666237" data-permission-text="Title is private" data-url="https://github.com/JuliaArrays/StaticArrays.jl/issues/665" data-hovercard-type="pull_request" data-hovercard-url="/JuliaArrays/StaticArrays.jl/pull/665/hovercard" href="https://github.com/JuliaArrays/StaticArrays.jl/pull/665">JuliaArrays/StaticArrays.jl#665</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398808003" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/30713" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/30713/hovercard" href="https://github.com/JuliaLang/julia/issues/30713">#30713</a>).</p>
</li>
<li>
<p dir="auto">Separate dispatches as in <code class="notranslate">foo(::Type{MyType})</code> and <code class="notranslate">foo(::Type{MyType{P}}) where P</code>.  <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="518317940" data-permission-text="Title is private" data-url="https://github.com/JuliaArrays/StaticArrays.jl/issues/685" data-hovercard-type="pull_request" data-hovercard-url="/JuliaArrays/StaticArrays.jl/pull/685/hovercard" href="https://github.com/JuliaArrays/StaticArrays.jl/pull/685">JuliaArrays/StaticArrays.jl#685</a> uses this solution.</p>
</li>
<li>
<p dir="auto">Write a helper function like <code class="notranslate">Type₁(U) = Type{T} where {P, U{P} &lt;: T &lt;: U}</code> and then define <code class="notranslate">foo(::Type₁(MyType))</code>.</p>
</li>
</ol>
<p dir="auto">However, none of the above solutions works well when there are many parameters.  It may be useful to have a generalization of approach 3 (say) <code class="notranslate">Type₊(U::UnionAll)</code> that works with an arbitrary number of parameters.  Or maybe there is a better solution?</p>