title: Why can't I get the class of a generic parameter?
body: <p>I have a function which takes one argument of a generic type and I want to access the class of it:</p>
  
  <pre><code>fun &lt;T&gt; test(t: T) {
      t::class
  }
  </code></pre>
  
  <p>This fails with "expression in class literal has nullable type". That's ok, I understand it (I could use <code>Any?</code> as my <code>T</code> and <code>null</code> as the value). <br>
  But if I change it to guaranty that <code>t</code> is not-null it still fails with the same error message:</p>
  
  <pre><code>fun &lt;T&gt; test(t: T) {
      t!!::class
  }
  </code></pre>
  
  <p>In which case can <code>t!!::class</code> still cause trouble? <br>
  Is there a way to get the class without using Any (or casting to Any)?</p>