<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; module temp
       struct x end
       end
Main.temp

julia&gt; using Main.temp

julia&gt; f(::temp.x) = 1
f (generic function with 1 method)

julia&gt; f(temp.x())
1

julia&gt; module temp
       struct x end
       end
WARNING: replacing module temp.
Main.temp

julia&gt; f(temp.x())
ERROR: MethodError: no method matching f(::Main.temp.x)
Closest candidates are:
  f(::Main.temp.x) at REPL[3]:1
Stacktrace:
 [1] top-level scope
   @ REPL[6]:1"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-k">module</span> temp
       <span class="pl-k">struct</span> x <span class="pl-k">end</span>
       <span class="pl-k">end</span>
Main<span class="pl-k">.</span>temp

julia<span class="pl-k">&gt;</span> <span class="pl-k">using</span> Main<span class="pl-k">.</span>temp

julia<span class="pl-k">&gt;</span> <span class="pl-en">f</span>(<span class="pl-k">::</span><span class="pl-c1">temp.x</span>) <span class="pl-k">=</span> <span class="pl-c1">1</span>
f (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">f</span>(temp<span class="pl-k">.</span><span class="pl-c1">x</span>())
<span class="pl-c1">1</span>

julia<span class="pl-k">&gt;</span> <span class="pl-k">module</span> temp
       <span class="pl-k">struct</span> x <span class="pl-k">end</span>
       <span class="pl-k">end</span>
WARNING<span class="pl-k">:</span> replacing <span class="pl-k">module</span> temp.
Main<span class="pl-k">.</span>temp

julia<span class="pl-k">&gt;</span> <span class="pl-c1">f</span>(temp<span class="pl-k">.</span><span class="pl-c1">x</span>())
ERROR<span class="pl-k">:</span> MethodError<span class="pl-k">:</span> no method matching <span class="pl-c1">f</span>(<span class="pl-k">::</span><span class="pl-c1">Main.temp.x</span>)
Closest candidates are<span class="pl-k">:</span>
  <span class="pl-c1">f</span>(<span class="pl-k">::</span><span class="pl-c1">Main.temp.x</span>) 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
   @ REPL[<span class="pl-c1">6</span>]<span class="pl-k">:</span><span class="pl-c1">1</span></pre></div>
<p dir="auto">In this case perhaps there might be a way to indicate that the present module differs from the one for which the method had been added? The closest candidate is confusing otherwise.</p>
<p dir="auto">Here's a MWE on v1.6.1:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="struct Foo end

f = Foo()

module Bar
export Foo, func
struct Foo end

func(f::Foo) = &quot;hi&quot;
end # module

using .Bar

func(f)  # Error: can't dispatch

# Then I did:
f isa Foo
methods(func)  # Only one method found 

# I should have checked:
f isa Bar.Foo"><pre class="notranslate"><span class="pl-k">struct</span> Foo <span class="pl-k">end</span>

f <span class="pl-k">=</span> <span class="pl-c1">Foo</span>()

<span class="pl-k">module</span> Bar
<span class="pl-k">export</span> Foo, func
<span class="pl-k">struct</span> Foo <span class="pl-k">end</span>

<span class="pl-en">func</span>(f<span class="pl-k">::</span><span class="pl-c1">Foo</span>) <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">"</span>hi<span class="pl-pds">"</span></span>
<span class="pl-k">end</span> <span class="pl-c"><span class="pl-c">#</span> module</span>

<span class="pl-k">using</span> <span class="pl-k">.</span>Bar

<span class="pl-c1">func</span>(f)  <span class="pl-c"><span class="pl-c">#</span> Error: can't dispatch</span>

<span class="pl-c"><span class="pl-c">#</span> Then I did:</span>
f <span class="pl-k">isa</span> Foo
<span class="pl-c1">methods</span>(func)  <span class="pl-c"><span class="pl-c">#</span> Only one method found </span>

<span class="pl-c"><span class="pl-c">#</span> I should have checked:</span>
f <span class="pl-k">isa</span> Bar<span class="pl-k">.</span>Foo</pre></div>
<p dir="auto">If the error message could say there are two <code class="notranslate">Foo</code>s defined in different modules that would be helpful.</p>