mirror of
https://github.com/github/codeql.git
synced 2025-12-19 18:33:16 +01:00
Kotlin: Refactor extractStaticTypeAccessQualifier
Avoids a cast
This commit is contained in:
@@ -1544,19 +1544,18 @@ open class KotlinFileExtractor(
|
||||
}
|
||||
|
||||
private fun extractStaticTypeAccessQualifier(target: IrDeclaration, parentExpr: Label<out DbExprparent>, locId: Label<DbLocation>, enclosingCallable: Label<out DbCallable>, enclosingStmt: Label<out DbStmt>) {
|
||||
if (target.shouldExtractAsStaticMemberOfClass) {
|
||||
extractTypeAccessRecursive(target.parentAsClass.toRawType(), locId, parentExpr, -1, enclosingCallable, enclosingStmt)
|
||||
} else if (target.shouldExtractAsStaticMemberOfFile) {
|
||||
extractTypeAccess(useFileClassType(target.parent as IrFile), locId, parentExpr, -1, enclosingCallable, enclosingStmt)
|
||||
if (target.shouldExtractAsStatic) {
|
||||
val parent = target.parent
|
||||
if (parent is IrClass) {
|
||||
extractTypeAccessRecursive(parent.toRawType(), locId, parentExpr, -1, enclosingCallable, enclosingStmt)
|
||||
} else if (parent is IrFile) {
|
||||
extractTypeAccess(useFileClassType(parent), locId, parentExpr, -1, enclosingCallable, enclosingStmt)
|
||||
} else {
|
||||
logger.warnElement("Unexpected static type access qualifer ${parent.javaClass}", target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val IrDeclaration.shouldExtractAsStaticMemberOfClass: Boolean
|
||||
get() = this.shouldExtractAsStatic && parent is IrClass
|
||||
|
||||
private val IrDeclaration.shouldExtractAsStaticMemberOfFile: Boolean
|
||||
get() = this.shouldExtractAsStatic && parent is IrFile
|
||||
|
||||
private fun isStaticAnnotatedNonCompanionMember(f: IrSimpleFunction) =
|
||||
f.parentClassOrNull?.isNonCompanionObject == true &&
|
||||
(f.hasAnnotation(jvmStaticFqName) || f.correspondingPropertySymbol?.owner?.hasAnnotation(jvmStaticFqName) == true)
|
||||
|
||||
Reference in New Issue
Block a user