I was about to say the same. I wish it did, and applied the rule that null never matches.
You could probably trick it with an ugly cast though. ((Object)getScene()) instanceof Scene s Maybe? Scott > On Dec 5, 2023, at 3:43 PM, Michael Strauß <michaelstr...@gmail.com> wrote: > > Unfortunately, this doesn't work. The Java language doesn't allow a > pattern to be the same type as the expression. > > >> On Tue, Dec 5, 2023 at 1:27 PM John Hendrikx <john.hendr...@gmail.com> wrote: >> >> When this runs on the FX thread it has to be safe, but it's not very nice. >> >> These days you can do these kind of null chain checks like this: >> >> if (getScene() instanceof Scene s && s.getWindow() instanceof >> Window w && w.isShowing()) { >> >> } >> >> --John