<div dir="ltr"><div style="font-family:monospace" class="gmail_default">Hello Brian,<br><br>> Mostly, the warning is confusing. In an<br>> earlier preview, unconditional patterns<br>> were prohibited in instanceof because we<br>> were concerned of an asymmetry between<br>> `instanceof X` and `instanceof X x`. The<br>> asymmetry was resolved and unconditional<br>> patterns were allowed there<br><br>Thank you for your response. I understand now why the warning was put there in the first place - to prevent a potential point of confusion for users until the creases were ironed out.<br><br>I also understand the pain points involving null and making sure that they are handled properly in instanceof patterns and switch patterns. I do appreciate how we can handle null neatly in both, with null just returning false in instanceof, and case null being an option to us for switch patterns.<br><br>> Unconditionality is the basic building<br>> block of exhaustiveness (and pattern<br>> dominance.)  <br>> <br>> Note that unconditionality is a stronger<br>> condition than exhaustiveness, for reasons<br>> that have been explained in other mails.<br><br>If I understand correctly, this is sort of like how we use ::add as the building block of ::addAll.<br><br>More specifically, we enforce pattern dominance in switch patterns by ensuring that the pattern above is not unconditional for the pattern below.<br><br>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><br>Please correct me if either of those 2 is wrong.<br><br>> These should mean the same thing now.<br><br>I guess this is where my primary point of confusion is now.<br><br>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><br>I would understand if this was for other forms of pattern matching, since those may not have an answer to unconditionality yet. But it sounds like you are telling me that instanceof does.<br><br>And I don't think it is related to the fact that I am doing this for a record. I tested this on a String too and ran into the exact same problem.<br><br>      final String s = "s";<br>      <br>      if (s instanceof String output)<br>      {<br>      <br>         System.out.println("String match");<br>      <br>      }<br><br>UnconditionalPatternsPreviewWarning.java:15: warning: [preview] unconditional patterns in instanceof are a preview feature and may be removed in a future release.<br>      if (s instanceof String output)<br>                       ^<br>1 warning<br><br>Thank you for your help and insight!<br>David Alayachew<br></div></div>