Thanks for your message. Unfortunately, I’m not able to reproduce your issue.
And I think I know why. This rule actually relies on the compiler warnings and we had a bunch of problems with this in the past.
The reason why this error is happening is most likely in the incomplete semantic model. So in order to check it I need a little bit more input from your side:
I will have a look there. Actually, we haven’t updated Kotlin compiler dependency to 1.9 as it was released recently, but the latest SonarQube was released a few months before. We’re currently working on that and indeed this could affect the results.
After trying your reproducer I can confirm that I can’t reproduce this with the SQ version of 10.1 and I can’t reproduce it with the master build of our Kotlin analyzer.
I was able to reproduce the issue on LTS 9.9.
This happened due to the fact that In the LTS 9.9 version of SQ, the latest officially supported Kotlin version was 1.7. I think it is because Kotlin 1.8 appeared at a time when we already had a code freeze before LTS. We added support for Kotlin 1.8 later in the SQ 10. And we’re going to add support for Kotlin 1.9 soon.
This doesn’t mean that you can’t analyze your project with Kotlin 1.8 or 1.9 with the SQ LTS 9.9. In most cases, it works fine, unless new language features were introduced. However, there could be changes in the compiler that might lead to such FPs or FNs that you can observe in your case.
If you need to always have support for the latest languages versions, you should maybe consider switching to the latest SQ or SC (SonarCloud).