title: Check if Scala class is instance of T
body: <p>My application handles a lot of third party integrations. I have an abstract base class for third party integrations which specifies a bunch of methods that an integration class should handle – then certain integrations can be extended with additional functionality that is not available on all integrations.</p>
  
  <p>Basically it looks like this:</p>
  
  <pre><code>abstract class Integration { ... }
  trait SingleSignOn { ... }
  
  class NormalIntegration extends Integration {}
  class SingleSignOnIntegration extends Integration with SingleSignOn {}
  </code></pre>
  
  <p>I would like to be able to sort out all integrations that have a specific trait, and this is what I thought of as the basic solution:</p>
  
  <pre><code>val allIntegrations: Seq[Integration] = ...
  
  def integrationsWithTrait[T]: Seq[Integration] = {
    allIntegrations.filter(_.isInstanceOf[T])
  }
  </code></pre>
  
  <p>The usage is:</p>
  
  <pre><code>val singleSignOnIntegrations = integrationsWithTrait[SingleSignOn]
  </code></pre>
  
  <p>The issue is that <code>isInstanceOf[T]</code> always returns true (meaning I end up with <code>singleSignOnIntegrations == allIntegrations</code>), while hard coded <code>isInstanceOf[SingleSignOn]</code> works as intended.</p>
  
  <p>How do I fix <code>integrationsWithTrait</code> to work as I intend?</p>