I installed the latest JDK from Oracle (20.0.1), and created a New Project in IntelliJ (2022.3.3). I'm just using IntelliJ for the build, no gradle or maven yet. I tried to use some of the latest features and I get red underlines and errors in IntelliJ, with switch patterns for example. My "Language Level" is "SDK Default (X - Experimental features)". I see that when I open "Module Settings (F4)" > Project.
If I change the Language Level to "19 Preview", the red lines in editor go away, but I still get a compilation error.
java: invalid source release 19 with --enable-preview
(preview language features are only supported for release 20)
Even though I'm running JDK 20, there is no 20 in the list of choices for a project "Language Level".
If I change the language level back to "X- Experimental Features" and then add "--enable-preview" as both a compiler option (in Settings) and a runtime VM option (under my Run Configuration) then it works, except there are still red lines in IntelliJ's editor.
Is there any way to get the red lines to go away?