Kotlin 2.3 - Diagnostic Collector Exception in UselessAssignmentsCheck (source must not be null)

Hello Team,

We are observing a Kotlin analyzer exception during SonarQube analysis after upgrading to Kotlin 2.3.10.

Error:

ERROR: The diagnostic collector has been interrupted by an exception. The result may be incomplete
java.lang.IllegalArgumentException: source must not be null

Frequency:
Intermittent but reproducible with a minimal example

Environment:

  • SonarQube Server: 2025.2
  • Sonar Gradle plugin: 7.2.3.7755
  • Kotlin: 2.3.10
  • Gradle: 9.3.1
  • JDK: 21 (Temurin)
  • OS: macOS (arm64)

Reproduction Command:

./gradlew sonar \
  --console=plain \
  --info \
  -Dsonar.host.url=<SONAR_HOST_URL> \
  -Dsonar.token=<SONAR_TOKEN> \
  -Dsonar.inclusions='src/main/kotlin/repro/SonarKotlinRepro.kt'

Key Stacktrace:

org.sonarsource.kotlin.checks.UselessAssignmentsCheck.visitKtFile
org.jetbrains.kotlin.fir.analysis.checkers.expression.FirIncompatibleClassExpressionChecker

Minimal Reproducer:

package repro

interface SonarKotlinRepro {
    fun first(): String?
    fun second(): String?
    fun third(): Boolean
    fun fourth()
}

Observed Behavior:

  • Exception occurs during analysis
  • Analysis still completes successfully
  • No visible impact on coverage or final metrics

Suspected Cause:
Kotlin FIR (K2) incompatibility with Sonar rule UselessAssignmentsCheck.

Questions:

  • Is Kotlin 2.3 officially supported?
  • Is this a known issue?
  • Are there any recommended workarounds?

Thanks.

Hi,

Welcome to the community!

Your version is past EOL. You should update to either the latest version or the current LTA (long-term active version) at your earliest convenience. Your update path is:

2025.2 → 2026.1.2 → 2026.2 (last step optional)

You may find these resources helpful:

If you have questions about updating, feel free to open a new thread for that here.

If your error persists after update, please come back to us.

 
Ann