mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
Merge pull request #15606 from igfoo/igfoo/kt2
Kotlin: Fix build with latest 2.0.255 snapshots
This commit is contained in:
@@ -1617,8 +1617,9 @@ open class KotlinFileExtractor(
|
||||
cls.origin != IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB
|
||||
|
||||
private fun needsInterfaceForwarder(f: IrFunction) =
|
||||
// forAllMethodsWithBody means -Xjvm-default=all or all-compatibility, in which case real
|
||||
// Java default interfaces are used, and we don't need to do anything.
|
||||
// jvmDefaultModeEnabledIsEnabled means that -Xjvm-default=all or all-compatibility was
|
||||
// used, in which case real Java default interfaces are used, and we don't need to do
|
||||
// anything.
|
||||
// Otherwise, for a Kotlin-defined method inheriting a Kotlin-defined default, we need to
|
||||
// create a synthetic method like
|
||||
// `int f(int x) { return super.InterfaceWithDefault.f(x); }`, because kotlinc will generate
|
||||
@@ -1626,9 +1627,9 @@ open class KotlinFileExtractor(
|
||||
// (NB. kotlinc's actual implementation strategy is different -- it makes an inner class
|
||||
// called InterfaceWithDefault$DefaultImpls and stores the default methods
|
||||
// there to allow default method usage in Java < 8, but this is hopefully niche.
|
||||
!pluginContext.languageVersionSettings
|
||||
.getFlag(JvmAnalysisFlags.jvmDefaultMode)
|
||||
.forAllMethodsWithBody &&
|
||||
!jvmDefaultModeEnabledIsEnabled(
|
||||
pluginContext.languageVersionSettings
|
||||
.getFlag(JvmAnalysisFlags.jvmDefaultMode)) &&
|
||||
f.parentClassOrNull.let {
|
||||
it != null &&
|
||||
it.origin != IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB &&
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.github.codeql.utils.versions
|
||||
|
||||
import org.jetbrains.kotlin.config.JvmDefaultMode
|
||||
|
||||
fun jvmDefaultModeEnabledIsEnabled(jdm: JvmDefaultMode): Boolean {
|
||||
return jdm.forAllMethodsWithBody
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.github.codeql.utils.versions
|
||||
|
||||
import org.jetbrains.kotlin.config.JvmDefaultMode
|
||||
|
||||
fun jvmDefaultModeEnabledIsEnabled(jdm: JvmDefaultMode): Boolean {
|
||||
return jdm.isEnabled
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.github.codeql.utils.versions
|
||||
|
||||
import com.github.codeql.utils.Psi2IrFacade
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.ir.PsiSourceManager
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.getKtFile
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
|
||||
fun getPsi2Ir(): Psi2IrFacade? = Psi2Ir()
|
||||
|
||||
private class Psi2Ir() : Psi2IrFacade {
|
||||
override fun getKtFile(irFile: IrFile): KtFile? {
|
||||
return irFile.getKtFile()
|
||||
}
|
||||
|
||||
override fun findPsiElement(irElement: IrElement, irFile: IrFile): PsiElement? {
|
||||
return PsiSourceManager.findPsiElement(irElement, irFile)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user