Kotlin: Fix handling of objects in external dependencies

This commit is contained in:
Ian Lynagh
2021-11-08 17:47:42 +00:00
parent b460c92c61
commit f726e6acf8
3 changed files with 17 additions and 18 deletions

View File

@@ -906,7 +906,7 @@ open class KotlinFileExtractor(
if(!c.isNonCompanionObject) {
logger.warn(Severity.ErrorSevere, "Using instance for non-object class")
}
val classId = useClassSource(c)
val classId = useClassInstance(c, listOf()).classLabel
val instanceName = "INSTANCE"
val instanceLabel = "@\"field;{$classId};$instanceName\""
val instanceId: Label<DbField> = tw.getLabelFor(instanceLabel)
@@ -1657,20 +1657,15 @@ open class KotlinFileExtractor(
// field that we are accessing here.
val exprParent = parent.expr(e, callable)
val c: IrClass = e.symbol.owner
// TODO: If this is enabled for Unit then it currently makes tests fail
if(c.name.asString() == "Unit") {
logger.warnElement(Severity.ErrorSevere, "Unit object not handled yet", e)
} else {
val instance = useObjectClassInstance(c)
val instance = useObjectClassInstance(c)
val id = tw.getFreshIdLabel<DbVaraccess>()
val type = useType(e.type)
val locId = tw.getLocation(e)
tw.writeExprs_varaccess(id, type.javaResult.id, type.kotlinResult.id, exprParent.parent, exprParent.idx)
tw.writeHasLocation(id, locId)
val id = tw.getFreshIdLabel<DbVaraccess>()
val type = useType(e.type)
val locId = tw.getLocation(e)
tw.writeExprs_varaccess(id, type.javaResult.id, type.kotlinResult.id, exprParent.parent, exprParent.idx)
tw.writeHasLocation(id, locId)
tw.writeVariableBinding(id, instance.id)
}
tw.writeVariableBinding(id, instance.id)
}
else -> {
logger.warnElement(Severity.ErrorSevere, "Unrecognised IrExpression: " + e.javaClass, e)