title: Type Inference failed, but cannot check for instance of erased type
body: <p>I have some logic that runs only when an object read from in FileInputStream is a Map:</p>
  
  <pre><code>  private fun loadEncryptedFile(file: File, password: CharArray) {
  
  
          var decrypted: ByteArray? = null
          ObjectInputStream(FileInputStream(file)).use {
  
              when (val data = it.readObject()) {
                  is Map&lt;*, *&gt; -&gt; {
  
                      if (data.containsKey("iv") &amp;&amp; data.containsKey("salt") &amp;&amp; data.containsKey("encrypted")) {
                          val iv = data["iv"]
                          val salt = data["salt"]
                          val encrypted = data["encrypted"]
                          if (iv is ByteArray &amp;&amp; salt is ByteArray &amp;&amp; encrypted is ByteArray) {
                              decrypted = Encryption().decrypt(
                                      hashMapOf("iv" to iv, "salt" to salt, "encrypted" to encrypted), password)
                          }
                      }
                  }
              }
          }
  }
  </code></pre>
  
  <p>Every instance of the "data" variable gives me a "Type inference failed, the value of parameter K should be mentioned in input types" error.</p>
  
  <p>However, replacing the wild cards with those types gives me the "Cannot check for instance of erased types" error. Where does the compiler want me to tell it what types are contained in the Map?</p>