Kotlin: How can I invoke a lambda field which has a generic type of its class?
<p>How can I invoke a lambda field which has a generic type of its class? For some reason, a reference to such a generic class like <code>Example&lt;*&gt;</code> yields an accept that replaces the original type (like <code>Example&lt;Something&gt;</code>) with <code>Nothing</code>. How can I invoke such a lambda by only having reference to <code>Example&lt;*&gt;</code>?</p>

<p>Codebase I am having this problem with: <a href="https://github.com/Jire/Acelta/tree/master/src/main/kotlin/com/acelta/packet/incoming/packets" rel="nofollow">https://github.com/Jire/Acelta/tree/master/src/main/kotlin/com/acelta/packet/incoming/packets</a></p>

<p>I am trying to this code, but as you can see on the 5th line I cannot invoke the lambda because the accept type is <code>Nothing</code>.</p>

<pre><code>private val incoming = arrayOfNulls&lt;Packet&lt;*&gt;&gt;(256)

fun incoming(id: Int, packeteer: Packeteer) {
    val packet = incoming[id] ?: return
    packet.receive(packeteer, /* this is type Nothing! */)
}
</code></pre>