title: Sealed type parameter
body: <p>I was wondering if it would be possible to use Scala macros to generate something equivalent to the following:</p>
  
  <pre><code>sealed type Foo
  type Bar &lt;: Foo
  type Baz &lt;: Foo
  </code></pre>
  
  <p>Then the following expression would be recognized as not being exhaustive</p>
  
  <pre><code>(foo: Foo) match {
    case bar: Bar =&gt; ???
  }
  </code></pre>
  
  <p>Looking at the comments in <a href="https://github.com/scala/scala/blob/2.12.x/src/compiler/scala/tools/nsc/transform/patmat/PatternMatching.scala" rel="nofollow"><code>PatternMatching.scala</code></a>, it looks like there could be a way to communicate those constraints to the typechecker.</p>