<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="">
Mostly, the warning is confusing. In an earlier preview, unconditional patterns were prohibited in instanceof because we were concerned of an asymmetry between `instanceof X` and `instanceof X x`. The asymmetry was resolved and unconditional patterns were
allowed there, but the warning is still a little confusing.
<div class=""><br class="">
</div>
<div class="">
<blockquote type="cite" class="">
<div dir="ltr" class="">
<div class="gmail_default" style="font-family: monospace;">The fact that you all made this delineation meant that it is something worth denoting. Is there some (upcoming) functionality involving pattern-matching that depends on this delineation? <br class="">
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Unconditionality is the basic building block of exhaustiveness (and pattern dominance.) </div>
<div class=""><br class="">
</div>
<div class="">Note that unconditionality is a stronger condition than exhaustiveness, for reasons that have been explained in other mails.</div>
<div class=""><br class="">
</div>
<blockquote type="cite" class="">
<div dir="ltr" class="">
<div class="gmail_default" style="font-family: monospace;">Why make this delineation for the following snippet, but not the one below it?<br class="">
<br class="">
if (input instanceof Triple t) {} //error or warning, depending on what you compile with<br class="">
<br class="">
if (input instanceof Triple) {} //compiles fine and runs fine<br class="">
</div>
</div>
</blockquote>
<br class="">
</div>
<div class="">These should mean the same thing now. (Originally it did not, and we were worried this would be confusing, hence the restriction.) The main place where they didn’t was at null, and finding the right place to handle nullity was among the trickiest
aspects of getting this design result. Now, the construct (instanceof, switch, etc) gets first crack at the target, and gets to have opinions about nulls, and whether/when to proceed and try to match the pattern. So instanceof first checks for null and
short circuits to false in that case, and if not, it tries to match the pattern. (If the pattern is unconditional on the operand type no runtime test should be generated.)</div>
<div class=""><br class="">
</div>
</body>
</html>