title: Why is Scala's behavior in case of overloading with by-name parameters different from the case with by-value parameters?
body: <p>Given this Scala code:</p>
  
  <pre><code>object test {
  
    def byval(a: Int) = println("Int")
    def byval(a: Long) = println("Long")
  
    def byname(a: =&gt; Int) = println("=&gt; Int")
    def byname(a: =&gt; Long) = println("=&gt; Long")
  
    def main(args: Array[String]) {
        byval(5)
        byname(5)
    }
  }
  </code></pre>
  
  <p>the call byval(5) compiles correctly, but byname fails to compile:</p>
  
  <pre><code>ambiguous reference to overloaded definition
  </code></pre>
  
  <p>Why? I would expect to observe the same behavior for by-value and by-name parameters with respect to overloading… How can it be fixed?</p>