title: Scala: ambiguous reference to overloaded definition - best disambiguation?
body: <p>I have a follow-on question to the problem that the presence of overloaded method definitions with and without parameters leads to a compilation error, which is already discussed here: <a href="https://stackoverflow.com/questions/7498677">Why is this reference ambiguous?</a> </p>
  
  <p>To recap:</p>
  
  <pre><code> trait A { 
      def foo( s: String ) : String
      def foo : String = foo( "foo" )
   }
   object B extends A {
      def foo( s: String ) : String = s
   } 
   B.foo     // won't compile
  </code></pre>
  
  <p>results in the error message:</p>
  
  <pre><code> error: ambiguous reference to overloaded function
   both method foo in object B of type(s: String)String
   and method foo in trait A of type =&gt; String
   match expected type Unit
   B.foo
  </code></pre>
  
  <p>A solution that works is to provide the compiler with the expected type, like so:</p>
  
  <pre><code> val s: String = B.foo
  </code></pre>
  
  <p>Unfortunately, one may not always want to introduce an extra variable (e.g. within an assertion). One of the solutions recommended at least twice in the answers to the earlier article referenced above was to invoke the method with empty parentheses, like so:</p>
  
  <pre><code> B.foo()
  </code></pre>
  
  <p>Unfortunately, this leads to a similar compiler error (Scala 2.9.0.1):</p>
  
  <pre><code> (s: String)String &lt;and&gt;
   =&gt; String
   cannot be applied to ()
   B.foo()
  </code></pre>
  
  <p>Is this a bug, or was the recommended solution in error? 
  And ultimately: what options are there to do this concisely, as in:</p>
  
  <pre><code> assert( B.foo == "whatever" )
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code> val expected : String = B.foo
   assert( expected == "whatever" )
  </code></pre>
  
  <p>Thanks.</p>