ok, so for future reference, what solved this for me was as follows: shut down IntelliJ, shut down gradle daemons, delete ~/.gradle, delete $PROJECT, re-open/import the project in IDEA, wait for a while. the first indexing pass resulted in all red as before. but a few seconds later it decided to do another indexing run. after that the build.gradle.kts file came good.