title: Overload resolution ambiguity. All these functions match when calling a java function that accepts both primitive and object arguments
body: <p>I have some java methods that look like this:</p>
  
  <pre><code>String doSomeMath(int num){
   if (num&lt;0) 
    return "value not loaded yet, please wait";
   else
    return String.valueOf(num);
  }
  String doSomeMath(Integer num){
   if (num==null) 
    return "value not loaded yet, please wait";
   else
    return String.valueOf(num);
  }
  </code></pre>
  
  <p>But in kotlin if I try to call these methods</p>
  
  <pre><code>val i1:Int=whatever()
  val i2:Int?=nullableWhatever()
  val str1=doSomeMath(i1)
  val str2=doSomeMath(i2)
  </code></pre>
  
  <p>Obviously <code>i1</code> is most likely an <code>int</code> and <code>i2</code> definitely an <code>Integer</code> yet kotlin doesn't think so and gives <code>Overload resolution ambiguity. All these functions match</code> for both line 3 and line 4.
  How can I cast <code>i1</code> and <code>i2</code> to java <code>int</code> or <code>Integer</code>?</p>