mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Kotlin: Fix build with 2.1.0-Beta1
This commit is contained in:
@@ -27,30 +27,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection
|
||||
import org.jetbrains.kotlin.ir.util.companionObject
|
||||
import org.jetbrains.kotlin.ir.util.constructors
|
||||
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
|
||||
import org.jetbrains.kotlin.ir.util.hasAnnotation
|
||||
import org.jetbrains.kotlin.ir.util.hasInterfaceParent
|
||||
import org.jetbrains.kotlin.ir.util.isAnnotationClass
|
||||
import org.jetbrains.kotlin.ir.util.isAnonymousObject
|
||||
import org.jetbrains.kotlin.ir.util.isFakeOverride
|
||||
import org.jetbrains.kotlin.ir.util.isFunctionOrKFunction
|
||||
import org.jetbrains.kotlin.ir.util.isInterface
|
||||
import org.jetbrains.kotlin.ir.util.isLocal
|
||||
import org.jetbrains.kotlin.ir.util.isNonCompanionObject
|
||||
import org.jetbrains.kotlin.ir.util.isObject
|
||||
import org.jetbrains.kotlin.ir.util.isSuspend
|
||||
import org.jetbrains.kotlin.ir.util.isSuspendFunctionOrKFunction
|
||||
import org.jetbrains.kotlin.ir.util.isVararg
|
||||
import org.jetbrains.kotlin.ir.util.kotlinFqName
|
||||
import org.jetbrains.kotlin.ir.util.packageFqName
|
||||
import org.jetbrains.kotlin.ir.util.parentAsClass
|
||||
import org.jetbrains.kotlin.ir.util.parentClassOrNull
|
||||
import org.jetbrains.kotlin.ir.util.parents
|
||||
import org.jetbrains.kotlin.ir.util.primaryConstructor
|
||||
import org.jetbrains.kotlin.ir.util.render
|
||||
import org.jetbrains.kotlin.ir.util.target
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.load.java.NOT_NULL_ANNOTATIONS
|
||||
import org.jetbrains.kotlin.load.java.NULLABLE_ANNOTATIONS
|
||||
@@ -826,7 +803,7 @@ open class KotlinFileExtractor(
|
||||
fun exprId() = tw.getLabelFor<DbExpr>("@\"annotationExpr;{$parent};$idx\"")
|
||||
|
||||
return when (v) {
|
||||
is IrConst<*> -> {
|
||||
is CodeQLIrConst<*> -> {
|
||||
extractConstant(v, parent, idx, null, null, overrideId = exprId())
|
||||
}
|
||||
is IrGetEnumValue -> {
|
||||
@@ -5998,7 +5975,7 @@ open class KotlinFileExtractor(
|
||||
extractExpressionExpr(a, callable, id, i, exprParent.enclosingStmt)
|
||||
}
|
||||
}
|
||||
is IrConst<*> -> {
|
||||
is CodeQLIrConst<*> -> {
|
||||
val exprParent = parent.expr(e, callable)
|
||||
extractConstant(
|
||||
e,
|
||||
@@ -6210,9 +6187,9 @@ open class KotlinFileExtractor(
|
||||
if (
|
||||
(isAndAnd || isOrOr) &&
|
||||
e.branches.size == 2 &&
|
||||
(e.branches[1].condition as? IrConst<*>)?.value == true &&
|
||||
(e.branches[1].condition as? CodeQLIrConst<*>)?.value == true &&
|
||||
(e.branches[if (e.origin == IrStatementOrigin.ANDAND) 1 else 0].result
|
||||
as? IrConst<*>)
|
||||
as? CodeQLIrConst<*>)
|
||||
?.value == isOrOr
|
||||
) {
|
||||
|
||||
@@ -6868,7 +6845,7 @@ open class KotlinFileExtractor(
|
||||
}
|
||||
|
||||
private fun extractConstant(
|
||||
e: IrConst<*>,
|
||||
e: CodeQLIrConst<*>,
|
||||
parent: Label<out DbExprparent>,
|
||||
idx: Int,
|
||||
enclosingCallable: Label<out DbCallable>?,
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.github.codeql.utils.versions.*
|
||||
import com.semmle.extractor.java.OdasaOutput
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
|
||||
import org.jetbrains.kotlin.backend.common.ir.*
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.propertyIfAccessor
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.*
|
||||
import org.jetbrains.kotlin.codegen.JvmCodegenUtil
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.load.kotlin.getJvmModuleNameForDeserializedDescripto
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.NameUtils
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.propertyIfAccessor
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
|
||||
@@ -84,7 +85,7 @@ open class KotlinUsesExtractor(
|
||||
}
|
||||
|
||||
private fun extractFileClass(fqName: FqName): Label<out DbClassorinterface> {
|
||||
val pkg = if (fqName.isRoot()) "" else fqName.parent().asString()
|
||||
val pkg = if (fqName.codeQlIsRoot()) "" else fqName.parent().asString()
|
||||
val jvmName = fqName.shortName().asString()
|
||||
return extractFileClass(pkg, jvmName)
|
||||
}
|
||||
@@ -906,7 +907,7 @@ open class KotlinUsesExtractor(
|
||||
return arrayInfo.componentTypeResults
|
||||
}
|
||||
owner is IrClass -> {
|
||||
val args = if (s.isRawType()) null else s.arguments
|
||||
val args = if (s.codeQlIsRawType()) null else s.arguments
|
||||
|
||||
return useSimpleTypeClass(owner, args, s.isNullable())
|
||||
}
|
||||
@@ -1232,9 +1233,10 @@ open class KotlinUsesExtractor(
|
||||
// false if it has `@JvmSuppressWildcards(false)`,
|
||||
// and null if the annotation is not present.
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
private fun getWildcardSuppressionDirective(t: IrAnnotationContainer) =
|
||||
private fun getWildcardSuppressionDirective(t: IrAnnotationContainer): Boolean? =
|
||||
t.getAnnotation(jvmWildcardSuppressionAnnotation)?.let {
|
||||
(it.getValueArgument(0) as? IrConst<Boolean>)?.value ?: true
|
||||
@Suppress("USELESS_CAST") // `as? Boolean` is not needed for Kotlin < 2.1
|
||||
(it.getValueArgument(0) as? CodeQLIrConst<Boolean>)?.value as? Boolean ?: true
|
||||
}
|
||||
|
||||
private fun addJavaLoweringArgumentWildcards(
|
||||
|
||||
@@ -27,13 +27,7 @@ import org.jetbrains.kotlin.ir.expressions.IrClassReference
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrGetEnumValue
|
||||
import org.jetbrains.kotlin.ir.expressions.IrVararg
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrClassReferenceImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetEnumValueImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrReturnImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.types.typeWith
|
||||
import org.jetbrains.kotlin.ir.util.constructedClass
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.github.codeql.utils
|
||||
|
||||
import com.github.codeql.utils.versions.allOverriddenIncludingSelf
|
||||
import com.github.codeql.utils.versions.CodeQLIrConst
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.ir.declarations.IrAnnotationContainer
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConst
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
|
||||
@@ -82,7 +82,7 @@ fun getJvmName(container: IrAnnotationContainer): String? {
|
||||
if (owner is IrClass) {
|
||||
val aPkg = owner.packageFqName?.asString()
|
||||
val name = owner.name.asString()
|
||||
if (aPkg == "kotlin.jvm" && name == "JvmName" && v is IrConst<*>) {
|
||||
if (aPkg == "kotlin.jvm" && name == "JvmName" && v is CodeQLIrConst<*>) {
|
||||
val value = v.value
|
||||
if (value is String) {
|
||||
return value
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.DescriptorlessExternalPackageFragmentSymbol
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.github.codeql.utils.versions
|
||||
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConst
|
||||
|
||||
typealias CodeQLIrConst<T> = IrConst<T>
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.github.codeql.utils.versions
|
||||
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
fun FqName.codeQlIsRoot() = this.isRoot()
|
||||
@@ -3,4 +3,4 @@ package com.github.codeql.utils.versions
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.isRawType
|
||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||
|
||||
fun IrSimpleType.isRawType() = this.isRawType()
|
||||
fun IrSimpleType.codeQlIsRawType() = this.isRawType()
|
||||
|
||||
@@ -3,4 +3,4 @@ package com.github.codeql.utils.versions
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.isRawType
|
||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||
|
||||
fun IrSimpleType.isRawType() = this.isRawType()
|
||||
fun IrSimpleType.codeQlIsRawType() = this.isRawType()
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.github.codeql.utils.versions
|
||||
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConst
|
||||
|
||||
typealias CodeQLIrConst<T> = IrConst
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.github.codeql.utils.versions
|
||||
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
fun FqName.codeQlIsRoot() = this.isRoot
|
||||
Reference in New Issue
Block a user