Merge pull request #10506 from tamasvajk/kotlin-enum-type-access

Kotlin: Fix type access expressions in enum constructor calls
This commit is contained in:
Tamás Vajk
2022-09-27 12:42:30 +02:00
committed by GitHub
6 changed files with 24 additions and 12 deletions

View File

@@ -2498,11 +2498,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)
}
}