KAPT: Use reflection to access code, changed in JDK 21

#KT-57389 Fixed
This commit is contained in:
Ilmir Usmanov
2023-10-26 04:31:15 +02:00
committed by Space Team
parent 4f7c96ae43
commit 37417f7919
2 changed files with 10 additions and 3 deletions
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.kapt3.base.javac
import com.sun.tools.javac.tree.JCTree
import com.sun.tools.javac.tree.JCTree.JCImport
import com.sun.tools.javac.util.*
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType
import org.jetbrains.kotlin.kapt3.base.KaptContext
@@ -55,6 +56,8 @@ class KaptJavaLog(
private val _reportedDiagnostics = mutableListOf<JCDiagnostic>()
private val jcImportQualidField = JCImport::class.java.declaredFields.single { it.name == "qualid" }
override fun flush(kind: WriterKind?) {
super.flush(kind)
@@ -197,7 +200,7 @@ class KaptJavaLog(
val visitor = object : JCTree.Visitor() {
override fun visitImport(that: JCTree.JCImport) {
super.visitImport(that)
if (!found) that.qualid.accept(this)
if (!found) (jcImportQualidField.get(that) as JCTree).accept(this)
}
override fun visitSelect(that: JCTree.JCFieldAccess) {