<p dir="auto">MWE:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; g(::Ref{Union{Int, Other}}) where {Other} = Other
g (generic function with 1 method)

julia&gt; g(Ref{Union{Int, Float64}}(1))
Float64

julia&gt; g(Ref{Union{Int, Array}}(1))
ERROR: MethodError: no method matching g(::Base.RefValue{Union{Int64, Array}})
Closest candidates are:
  g(::Ref{Union{Int64, Other}}) where Other at REPL[3]:1
Stacktrace:
 [1] top-level scope at REPL[5]:1

julia&gt; versioninfo()
Julia Version 1.5.2
Commit 539f3ce943* (2020-09-23 23:17 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: AMD Ryzen 5 2600 Six-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, znver1)
Environment:
  JULIA_NUM_THREADS = 6
"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-en">g</span>(<span class="pl-k">::</span><span class="pl-c1">Ref{Union{Int, Other}}</span>) <span class="pl-k">where</span> {Other} <span class="pl-k">=</span> Other
g (generic <span class="pl-k">function</span> with <span class="pl-c1">1</span> method)

julia<span class="pl-k">&gt;</span> <span class="pl-c1">g</span>(<span class="pl-c1">Ref</span><span class="pl-c1">{Union{Int, Float64}}</span>(<span class="pl-c1">1</span>))
Float64

julia<span class="pl-k">&gt;</span> <span class="pl-c1">g</span>(<span class="pl-c1">Ref</span><span class="pl-c1">{Union{Int, Array}}</span>(<span class="pl-c1">1</span>))
ERROR<span class="pl-k">:</span> MethodError<span class="pl-k">:</span> no method matching <span class="pl-c1">g</span>(<span class="pl-k">::</span><span class="pl-c1">Base.RefValue{Union{Int64, Array}}</span>)
Closest candidates are<span class="pl-k">:</span>
  <span class="pl-c1">g</span>(<span class="pl-k">::</span><span class="pl-c1">Ref{Union{Int64, Other}}</span>) <span class="pl-k">where</span> Other at REPL[<span class="pl-c1">3</span>]<span class="pl-k">:</span><span class="pl-c1">1</span>
Stacktrace<span class="pl-k">:</span>
 [<span class="pl-c1">1</span>] top<span class="pl-k">-</span>level scope at REPL[<span class="pl-c1">5</span>]<span class="pl-k">:</span><span class="pl-c1">1</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">versioninfo</span>()
Julia Version <span class="pl-c1">1.5</span>.<span class="pl-c1">2</span>
Commit <span class="pl-c1">539f3</span>ce943<span class="pl-k">*</span> (<span class="pl-c1">2020</span><span class="pl-k">-</span><span class="pl-c1">09</span><span class="pl-k">-</span><span class="pl-c1">23</span> <span class="pl-c1">23</span><span class="pl-k">:</span><span class="pl-c1">17</span> UTC)
Platform Info<span class="pl-k">:</span>
  OS<span class="pl-k">:</span> Linux (x86_64<span class="pl-k">-</span>pc<span class="pl-k">-</span>linux<span class="pl-k">-</span>gnu)
  CPU<span class="pl-k">:</span> AMD Ryzen <span class="pl-c1">5</span> <span class="pl-c1">2600</span> Six<span class="pl-k">-</span>Core Processor
  WORD_SIZE<span class="pl-k">:</span> <span class="pl-c1">64</span>
  LIBM<span class="pl-k">:</span> libopenlibm
  LLVM<span class="pl-k">:</span> libLLVM<span class="pl-k">-</span><span class="pl-c1">9.0</span>.<span class="pl-c1">1</span> (ORCJIT, znver1)
Environment<span class="pl-k">:</span>
  JULIA_NUM_THREADS <span class="pl-k">=</span> <span class="pl-c1">6</span>
</pre></div>
<p dir="auto">Seems like a bug with <code class="notranslate">UnionAll</code> to me.</p>
<p dir="auto"><em>Originally posted by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/MasonProtter/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/MasonProtter">@MasonProtter</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="710619274" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/37790" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/37790/hovercard?comment_id=700409442&amp;comment_type=issue_comment" href="https://github.com/JuliaLang/julia/issues/37790#issuecomment-700409442">#37790 (comment)</a></em></p>
<p dir="auto">This might be a duplicate of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="642624025" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/36377" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/36377/hovercard" href="https://github.com/JuliaLang/julia/issues/36377">#36377</a>, not sure.</p>
<p dir="auto">Suppose I want to make a type</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="struct Foo{I &lt;: Integer}
    v::Vector{Complex{I}}
end"><pre class="notranslate"><code class="notranslate">struct Foo{I &lt;: Integer}
    v::Vector{Complex{I}}
end
</code></pre></div>
<p dir="auto">Now, at runtime, I have a vector of integer <code class="notranslate">Complex</code>, but I don't know <em>which</em> integer type, so I can just make an abstractly typed array:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; v = Complex{&lt;:Integer}[Complex{Int}(1, 1)]
1-element Array{Complex{var&quot;#s16&quot;} where var&quot;#s16&quot;&lt;:Integer,1}:
 1 + 1im"><pre class="notranslate"><code class="notranslate">julia&gt; v = Complex{&lt;:Integer}[Complex{Int}(1, 1)]
1-element Array{Complex{var"#s16"} where var"#s16"&lt;:Integer,1}:
 1 + 1im
</code></pre></div>
<p dir="auto">But now, how do I wrap <code class="notranslate">v</code> in a <code class="notranslate">Foo</code>?</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; Foo{&lt;:Integer}(v)
ERROR: MethodError: no method matching Foo{var&quot;#s12&quot;} where var&quot;#s12&quot;&lt;:Integer(::Array{Complex{var&quot;#s16&quot;} where var&quot;#s16&quot;&lt;:Integer,1})"><pre class="notranslate"><code class="notranslate">julia&gt; Foo{&lt;:Integer}(v)
ERROR: MethodError: no method matching Foo{var"#s12"} where var"#s12"&lt;:Integer(::Array{Complex{var"#s16"} where var"#s16"&lt;:Integer,1})
</code></pre></div>
<p dir="auto">One workaround is to instead define</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="struct Foo{C &lt;: Complex{&lt;:Integer}}
    v::Vector{C}
end"><pre class="notranslate"><code class="notranslate">struct Foo{C &lt;: Complex{&lt;:Integer}}
    v::Vector{C}
end
</code></pre></div>
<p dir="auto">But I think having <code class="notranslate">Complex</code> as part of <code class="notranslate">Foo</code>'s signature is unnecessary. Would it be possible to enable the "direct" use of <code class="notranslate">&lt;:Integer</code> in this case?</p>