Hi all, I am experimenting with Java generics and I have the following question (all the code in this email can be found at <a href="https://gist.github.com/ice1000/e376089438dd115c369329d00ee27779">https://gist.github.com/ice1000/e376089438dd115c369329d00ee27779</a>).<div><br></div><div>Here's some simple prelude definitions (the gist is more informative):</div><div><br></div><div><div style="color: rgb(8, 8, 8); font-family: "JetBrains Mono", monospace; font-size: 12pt; white-space: pre;"><span style="color: rgb(0, 51, 179);">sealed interface </span><span style="color: rgb(0, 0, 0);">Nat</span><<span style="color: rgb(0, 126, 138);">T </span><span style="color: rgb(0, 51, 179);">extends </span><span style="color: rgb(0, 0, 0);">Nat</span><<span style="color: rgb(0, 126, 138);">T</span>>> {}<br><span style="color: rgb(0, 51, 179);">record </span><span style="color: rgb(0, 0, 0);">Z</span>() <span style="color: rgb(0, 51, 179);">implements </span><span style="color: rgb(0, 0, 0);">Nat</span><<span style="color: rgb(0, 0, 0);">Z</span>> {}<br><span style="color: rgb(0, 51, 179);">record </span><span style="color: rgb(0, 0, 0);">S</span><<span style="color: rgb(0, 126, 138);">T </span><span style="color: rgb(0, 51, 179);">extends </span><span style="color: rgb(0, 0, 0);">Nat</span><<span style="color: rgb(0, 126, 138);">T</span>>>(<span style="color: rgb(0, 0, 0);">Nat</span><<span style="color: rgb(0, 126, 138);">T</span>> pred) <span style="color: rgb(0, 51, 179);">implements </span><span style="color: rgb(0, 0, 0);">Nat</span><<span style="color: rgb(0, 0, 0);">S</span><<span style="color: rgb(0, 126, 138);">T</span>>> {}<br><br><span style="color: rgb(0, 51, 179);">sealed interface </span><span style="color: rgb(0, 0, 0);">Fin</span><<span style="color: rgb(0, 126, 138);">T </span><span style="color: rgb(0, 51, 179);">extends </span><span style="color: rgb(0, 0, 0);">Nat</span><<span style="color: rgb(0, 126, 138);">T</span>>> {}<br><span style="color: rgb(0, 51, 179);">record </span><span style="color: rgb(0, 0, 0);">FZ</span><<span style="color: rgb(0, 126, 138);">T </span><span style="color: rgb(0, 51, 179);">extends </span><span style="color: rgb(0, 0, 0);">Nat</span><<span style="color: rgb(0, 126, 138);">T</span>>>() <span style="color: rgb(0, 51, 179);">implements </span><span style="color: rgb(0, 0, 0);">Fin</span><<span style="color: rgb(0, 0, 0);">S</span><<span style="color: rgb(0, 126, 138);">T</span>>> {}<br><span style="color: rgb(0, 51, 179);">record </span><span style="color: rgb(0, 0, 0);">FS</span><<span style="color: rgb(0, 126, 138);">T </span><span style="color: rgb(0, 51, 179);">extends </span><span style="color: rgb(0, 0, 0);">Nat</span><<span style="color: rgb(0, 126, 138);">T</span>>>(<span style="color: rgb(0, 0, 0);">Fin</span><<span style="color: rgb(0, 126, 138);">T</span>> pred) <span style="color: rgb(0, 51, 179);">implements </span><span style="color: rgb(0, 0, 0);">Fin</span><<span style="color: rgb(0, 0, 0);">S</span><<span style="color: rgb(0, 126, 138);">T</span>>> {}</div></div><div style="color: rgb(8, 8, 8); font-family: "JetBrains Mono", monospace; font-size: 12pt; white-space: pre;"><br></div><div style="color: rgb(8, 8, 8); font-family: "JetBrains Mono", monospace; font-size: 12pt; white-space: pre;"><span style="color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; white-space: normal;">From the definition, it is obvious that Fin<Z> is an empty type, but switching over an instance of that type still requires clauses (which, for whatever I write, there will be a type error unless I use raw generics). I would like to know the current design decisions here.</span></div><div style="color: rgb(8, 8, 8); font-family: "JetBrains Mono", monospace; font-size: 12pt; white-space: pre;"><br></div><div style="font-family: "JetBrains Mono", monospace; font-size: 12pt; white-space: pre;"><div style="font-size: 12pt;"><span style="color: rgb(0, 51, 179);">static void </span><span style="color: rgb(0, 98, 122);">empty</span><font color="#080808">(</font><span style="color: rgb(0, 0, 0);">Fin</span><font color="#080808"><</font><span style="color: rgb(0, 0, 0);">Z</span><font color="#080808">> fin) {<br>  </font><span style="color: rgb(0, 0, 0);">String s</span><font color="#080808"> = </font><span style="color: rgb(0, 51, 179);">switch </span><font color="#080808">(fin) {<br>  };<br>}</font><font color="#080808"><br></font></div></div><div style="color: rgb(8, 8, 8); font-family: "JetBrains Mono", monospace; font-size: 12pt; white-space: pre;"><br></div><div style="color: rgb(8, 8, 8); font-family: "JetBrains Mono", monospace; font-size: 12pt; white-space: pre;"><div style="font-size: 12pt;"><span style="color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; white-space: normal;">Also, it would be nice if switching `Fin<S<Z>>` can elide the case for `FS` because the only possible instance of such type is `new FS<>(null)`, but I understand why it doesn't work. It's a shame that we still have nulls to deal with :(</span></div><div style="font-size: 12pt;"><span style="color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; white-space: normal;"><br></span></div><div style="font-size: 12pt;"><span style="color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; white-space: normal;">Best regards and cheers,</span></div><div style="font-size: 12pt;"><span style="color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; white-space: normal;">Tesla</span></div><div><span style="color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; white-space: normal;"><br></span></div></div>