mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
Only convert KClass -> Class in annotation context
This commit is contained in:
@@ -512,14 +512,14 @@ open class KotlinFileExtractor(
|
||||
is IrClassReference -> {
|
||||
val classRefId = exprId()
|
||||
val typeAccessId = tw.getLabelFor<DbUnannotatedtypeaccess>("@\"annotationExpr;{$classRefId};0\"")
|
||||
extractClassReference(v, parent, idx, null, null, overrideId = classRefId, typeAccessOverrideId = typeAccessId, useUnboundType = true)
|
||||
extractClassReference(v, parent, idx, null, null, overrideId = classRefId, typeAccessOverrideId = typeAccessId, useJavaLangClassType = true)
|
||||
}
|
||||
is IrConstructorCall -> {
|
||||
extractAnnotation(v, parent, idx, contextLabel)
|
||||
}
|
||||
is IrVararg -> {
|
||||
tw.getLabelFor<DbArrayinit>("@\"annotationarray;{${parent}};$contextLabel\"").also { arrayId ->
|
||||
val type = useType(v.type)
|
||||
val type = useType(kClassToJavaClass(v.type))
|
||||
tw.writeExprs_arrayinit(arrayId, type.javaResult.id, parent, idx)
|
||||
tw.writeExprsKotlinType(arrayId, type.kotlinResult.id)
|
||||
tw.writeHasLocation(arrayId, tw.getLocation(v))
|
||||
@@ -4195,11 +4195,12 @@ open class KotlinFileExtractor(
|
||||
enclosingStmt: Label<out DbStmt>?,
|
||||
overrideId: Label<out DbExpr>? = null,
|
||||
typeAccessOverrideId: Label<out DbExpr>? = null,
|
||||
useUnboundType: Boolean = false
|
||||
useJavaLangClassType: Boolean = false
|
||||
) =
|
||||
exprIdOrFresh<DbTypeliteral>(overrideId).also { id ->
|
||||
val locId = tw.getLocation(e)
|
||||
val type = useType(if (useUnboundType) toUnbound(e.type) else e.type)
|
||||
val jlcType = if (useJavaLangClassType) this.javaLangClass?.let { it.typeWith() } else null
|
||||
val type = useType(jlcType ?: e.type)
|
||||
tw.writeExprs_typeliteral(id, type.javaResult.id, parent, idx)
|
||||
tw.writeExprsKotlinType(id, type.kotlinResult.id)
|
||||
extractExprContext(id, locId, enclosingCallable, enclosingStmt)
|
||||
|
||||
@@ -120,10 +120,4 @@ fun getContainingClassOrSelf(decl: IrDeclaration): IrClass? {
|
||||
}
|
||||
|
||||
fun getJavaEquivalentClassId(c: IrClass) =
|
||||
c.fqNameWhenAvailable?.toUnsafe()?.let {
|
||||
if (it.asString() == "kotlin.reflect.KClass") {
|
||||
ClassId.fromString("java.lang.Class")
|
||||
} else {
|
||||
JavaToKotlinClassMap.mapKotlinToJava(it)
|
||||
}
|
||||
}
|
||||
c.fqNameWhenAvailable?.toUnsafe()?.let { JavaToKotlinClassMap.mapKotlinToJava(it) }
|
||||
|
||||
Reference in New Issue
Block a user