<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<br class="">
<div>
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div style="font-family:monospace" class="gmail_default">More specifically, we enforce pattern dominance in switch patterns by ensuring that the pattern above is not unconditional for the pattern below.<br class="">
</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>Essentially yes, though its more subtle than that.  But where unconditionality is really important is in nesting.  Suppose I have</div>
<div><br class="">
</div>
<div>    record Box(Object o) { … }</div>
<div><br class="">
</div>
<div>and</div>
<div><br class="">
</div>
<div>    switch (box) { </div>
<div>        case Box(Object o):  B;</div>
<div><br class="">
</div>
<div>        case Box b: // dead</div>
<div>    }</div>
<div><br class="">
</div>
<div>We can conclude the second pattern is dominated because not only is there a “case Box(…)” above it, but the pattern nested inside it (Object o) is unconditional on the component of Box.  If the first pattern were `case Box(Integer i)`, the `case Box b`
 would not be dead.  </div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div style="font-family:monospace" class="gmail_default">And we can enforce exhaustiveness by making sure the final pattern in switch patterns is the only one that is unconditional on the parameter.<br class="">
</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>That’s one way to get exhaustiveness, but not the only way.  If I have a sealed type A = B|C, then if the switch exhausts B and C, then it exhausts A, even without any sort of `case A` pattern.  </div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div style="font-family:monospace" class="gmail_default">It sounds like the creases have been ironed out at this point between instanceof pattern matching and unconditionality. So why does the warning still exist for instanceof pattern matching?<br class="">
</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>As I said, the warning is  confusingly worded, and will go away when we exit preview (which is hopefully soon.)</div>
<br class="">
</div>
<br class="">
</body>
</html>