From 3d6c6d9c768b8209be796153d4a2a543c77c99a1 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Thu, 12 Sep 2024 18:06:24 +0000 Subject: Use -language-version 1.9 in the kotlinKythe build rule There are some instances of .kt code in android platform that are not fully compatible with kotlinc > 2. To account for this version skew when generating xrefs, implicitly add `-language-version 1.9` to the args in the .kzip file. The main kotlinc build rules remain the same. This value has been picked manually by running `external/kotlinc/bin/kotlinc -version` at ToT Bug: 265428637 Test: verified that `-language-version 1.9` is added to the build command of the .kzip files Test: ran the indexer locally on the .kzip of `PermissionController-lib` (this android_library contains .kt code that does not compile with verison >2) Change-Id: Icfb72800404d83f63204de23a1ec34b40ee05847 --- java/config/kotlin.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'java/config/kotlin.go') diff --git a/java/config/kotlin.go b/java/config/kotlin.go index e5e187cad..302d021db 100644 --- a/java/config/kotlin.go +++ b/java/config/kotlin.go @@ -50,4 +50,11 @@ func init() { }, " ")) pctx.StaticVariable("KotlincGlobalFlags", strings.Join([]string{}, " ")) + // Use KotlincKytheGlobalFlags to prevent kotlinc version skew issues between android and + // g3 kythe indexers. + // This is necessary because there might be instances of kotlin code in android + // platform that are not fully compatible with the kotlinc used in g3 kythe indexers. + // e.g. uninitialized variables are a warning in 1.*, but an error in 2.* + // https://github.com/JetBrains/kotlin/blob/master/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt#L748 + pctx.StaticVariable("KotlincKytheGlobalFlags", strings.Join([]string{"-language-version 1.9"}, " ")) } -- cgit v1.2.3-59-g8ed1b