<div dir="ltr">Hello!<br><div><br></div><div>Suppose we declare several instance patterns and define that they form an exhaustive set (using syntax from the bikeshed thread):</div><div><br></div><div>class X {</div><div>  case pattern(String that) p1() {...}</div><div>  case pattern(String that) p2() {...}</div><div>}</div><div><br></div><div>To match, we need an instance of type X. Could it be an arbitrary expression, or it should be a limited thing (e.g., only a local variable)? And how the exhaustiveness will be determined? E.g.:</div><div><br></div><div>X myX = ...</div><div>switch(str) {</div><div>  case myX.p1() -> {...}</div><div>  case myX.p2() -> {...}</div><div>}</div><div><br></div><div>Here, we can assume that the set of cases is exhaustive, because p1() and p2() have the same effectively-final qualifier. But what if it's a method call?</div><div><br></div><div><div>switch(str) {</div><div>  case getX().p1() -> {...}</div><div>  case getX().p2() -> {...}</div><div>}</div><div><br></div></div><div>The `getX()` method may return different instances of X, and it's not evident anymore whether this set of patterns is exhaustive. Do we have any strategy regarding this case? Or exhaustive sets are not allowed for instance patterns?</div><div><br></div><div>With kind regards,</div><div>Tagir Valeev</div></div>