<div dir="ltr"><div>Hi!<br>I investigated the algorithm, which Javac 21 (Build 30 (2023/7/6))</div><div>) uses to check exhaustiveness for record patterns (JEP 440+441), and found the strange behavior:<br>- let's take compilable code<br>```<br>class Test22 {<br><br>  record Pair(I i1, I i2) {}<br><br>  sealed interface I {}<br><br>  record C() implements I {}<br><br>  record D() implements I {}<br><br>  void exhaustinvenessWithInterface(Pair pairI) {<br>    switch (pairI) {<br>      case Pair(C fst, D snd) -> {<br>      }<br>      case Pair(C fst, C snd) -> {<br>      }<br>      case Pair(I fst, C snd) -> {<br>      }<br>      case Pair(D fst, D snd) -> {<br>      }<br>    }<br>  }<br>}<br>```<br>- If we swap types of components, it starts to produce the error "java: the switch statement does not cover all possible input values":<br>```<br>  void exhaustinvenessWithInterface(Pair pairI) {<br>    switch (pairI) {<br>      case Pair(D fst, C snd) -> {<br>      }<br>      case Pair(C fst, C snd) -> {<br>      }<br>      case Pair(C fst, I snd) -> {<br>      }<br>      case Pair(D fst, D snd) -> {<br>      }<br>    }<br>  }<br>```<br>It happens because Javac tries to find the first distinguished type from the beginning, but I couldn't find any mention of it in JEP.<br>Is this the expected behavior?<br><br></div></div>