mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
Kotlin: Fix type access expressions in enum constructor calls
This commit is contained in:
@@ -2482,11 +2482,23 @@ open class KotlinFileExtractor(
|
||||
|
||||
if (e is IrConstructorCall) {
|
||||
extractConstructorTypeAccess(eType, typeAccessType, e.symbol, locId, id, -3, callable, enclosingStmt)
|
||||
} else {
|
||||
val typeAccessId =
|
||||
extractTypeAccess(typeAccessType, locId, id, -3, callable, enclosingStmt)
|
||||
} else if (e is IrEnumConstructorCall) {
|
||||
val enumClass = e.symbol.owner.parent as? IrClass
|
||||
if (enumClass == null) {
|
||||
logger.warnElement("Couldn't find declaring class of enum constructor call", e)
|
||||
return
|
||||
}
|
||||
|
||||
extractTypeArguments(e, typeAccessId, callable, enclosingStmt)
|
||||
val args = (0 until e.typeArgumentsCount).map { e.getTypeArgument(it) }.requireNoNullsOrNull()
|
||||
if (args == null) {
|
||||
logger.warnElement("Found null type argument in enum constructor call", e)
|
||||
return
|
||||
}
|
||||
|
||||
val enumType = enumClass.typeWith(args)
|
||||
extractConstructorTypeAccess(enumType, useType(enumType), e.symbol, locId, id, -3, callable, enclosingStmt)
|
||||
} else {
|
||||
logger.errorElement("Unexpected constructor call type: ${e.javaClass}", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user