Is it possible to call an overloaded function from overwriting function in Julia?
<p>The problem is the following:</p>
<p>I have an abstract type <code>MyAbstract</code> and derived composite types <code>MyType1</code> and <code>MyType2</code>:</p>
<pre><code>abstract type MyAbstract end

struct MyType1 &lt;: MyAbstract
    somestuff
end

struct MyType2 &lt;: MyAbstract
    someotherstuff
end
</code></pre>
<p>I want to specify some general behaviour for objects of type <code>MyAbstract</code>, so I have a function</p>
<pre><code>function dosth(x::MyAbstract)
    println(1) # instead of something useful
end
</code></pre>
<p>This general behaviour suffices for <code>MyType1</code> but when <code>dosth</code> is called with an argument of type <code>MyType2</code>, I want some additional things to happen that are specific for <code>MyType2</code> and, of course, I want to reuse the existing code, so I tried the following, but it did not work:</p>
<pre><code>function dosth(x::MyType2)
    dosth(x::MyAbstract)
    println(2)
end

x = MyType2(&quot;&quot;)
dosth(x) # StackOverflowError
</code></pre>
<p>This means Julia did not recognize my attempt to treat <code>x</code> like its &quot;supertype&quot; for some time.</p>
<p>Is it possible to call an overloaded function from the overwriting function in Julia? How can I elegantly solve this problem?</p>