title: jackson IntelliJ error when converting to unknown type in kotlin
body: <p>In Kotlin, when trying to convert a request body into a Kotlin Object I get the following error in IntelliJ:</p>
  <blockquote>
  <p>None of the following function can be called with the arguments supplied</p>
  </blockquote>
  <p>That's because it cannot infer the type of the object to convert to.</p>
  <p>The application still builds and runs perfectly.</p>
  <p>The IDE is right that it cannot infer the type of the resulting object but at runtime everything works as expected. The body is determined and then the deserialization is done properly and converted to the expected object type.</p>
  <p>Even if this works the problem is only that I have the IDE error present in code.</p>
  <pre class="lang-kotlin prettyprint-override"><code>
  val bodyMapper = payloadMapper(type)
  val body = ObjectMapper().readValue(it.getPayload(), bodyMapper)
  val body1 = jacksonObjectMapper().readValue(it.getPayload(), bodyMapper)
  
  private fun payloadMapper(type: String): Class&lt;out Any&gt; {
      return when (type) {
          &quot;X&quot; -&gt; X::class.java
  }
  </code></pre>
  <p>I use <code>jackson</code> and <code>jackson-kotlin</code>.</p>
  <pre><code>kotlin(&quot;jvm&quot;) version &quot;1.4.21&quot;
  kotlin(&quot;plugin.spring&quot;) version &quot;1.4.21&quot;
  id(&quot;org.springframework.boot&quot;) version &quot;2.3.5.RELEASE&quot;
  id(&quot;io.spring.dependency-management&quot;) version &quot;1.0.10.RELEASE&quot;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/CeRgx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CeRgx.png" alt="" /></a></p>
  <p>The IDE error.</p>
  <p><a href="https://i.stack.imgur.com/dQV4X.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dQV4X.png" alt="" /></a></p>