Fix some bugs appeared in 610c9b52
* Property references in top-level initializers * Empty String constructor * Special case when inheriting multiple method implementations * Getting IR for error types
This commit is contained in:
committed by
SvyatoslavScherbina
parent
18b7bb31fc
commit
e0d5a5d167
+33
-5
@@ -48,14 +48,42 @@ internal val ClassDescriptor.implementedInterfaces: List<ClassDescriptor>
|
||||
*
|
||||
* TODO: this method is actually a part of resolve and probably duplicates another one
|
||||
*/
|
||||
internal tailrec fun IrSimpleFunction.resolveFakeOverride(): IrSimpleFunction {
|
||||
internal fun IrSimpleFunction.resolveFakeOverride(): IrSimpleFunction {
|
||||
if (this.isReal) {
|
||||
return this
|
||||
} else {
|
||||
return overriddenSymbols
|
||||
.firstOrNull { it.owner.modality != Modality.ABSTRACT }!!
|
||||
.owner.resolveFakeOverride()
|
||||
}
|
||||
|
||||
val visited = mutableSetOf<IrSimpleFunction>()
|
||||
val realSupers = mutableSetOf<IrSimpleFunction>()
|
||||
|
||||
fun findRealSupers(function: IrSimpleFunction) {
|
||||
if (function in visited) return
|
||||
visited += function
|
||||
if (function.isReal) {
|
||||
realSupers += function
|
||||
} else {
|
||||
function.overriddenSymbols.forEach { findRealSupers(it.owner) }
|
||||
}
|
||||
}
|
||||
|
||||
findRealSupers(this)
|
||||
|
||||
if (realSupers.size > 1) {
|
||||
visited.clear()
|
||||
|
||||
fun excludeOverridden(function: IrSimpleFunction) {
|
||||
if (function in visited) return
|
||||
visited += function
|
||||
function.overriddenSymbols.forEach {
|
||||
realSupers.remove(it.owner)
|
||||
excludeOverridden(it.owner)
|
||||
}
|
||||
}
|
||||
|
||||
realSupers.toList().forEach { excludeOverridden(it) }
|
||||
}
|
||||
|
||||
return realSupers.first { it.modality != Modality.ABSTRACT }
|
||||
}
|
||||
|
||||
private val intrinsicAnnotation = FqName("konan.internal.Intrinsic")
|
||||
|
||||
+2
-1
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
|
||||
@@ -178,7 +179,7 @@ fun IrModuleFragment.referenceAllTypeExternalClassifiers(symbolTable: SymbolTabl
|
||||
|
||||
fun KotlinType.referenceAllClassifiers() {
|
||||
TypeUtils.getClassDescriptor(this)?.let {
|
||||
if (it.module != moduleDescriptor) {
|
||||
if (!ErrorUtils.isError(it) && it.module != moduleDescriptor) {
|
||||
if (it.kind == ClassKind.ENUM_ENTRY) {
|
||||
symbolTable.referenceEnumEntry(it)
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -1990,7 +1990,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
||||
assert(args.isNotEmpty() && args[0].type == int32Type)
|
||||
functionGenerationContext.allocArray(codegen.typeInfoValue(constructedClass), args[0],
|
||||
resultLifetime(callee))
|
||||
} else if (constructedClass == context.builtIns.string) {
|
||||
} else if (constructedClass == context.ir.symbols.string.owner) {
|
||||
// TODO: consider returning the empty string literal instead.
|
||||
assert(args.isEmpty())
|
||||
functionGenerationContext.allocArray(codegen.typeInfoValue(constructedClass), count = kImmZero,
|
||||
|
||||
+3
-1
@@ -190,10 +190,12 @@ internal class PropertyDelegationLowering(val context: KonanBackendContext) : Fi
|
||||
if (kProperties.isNotEmpty()) {
|
||||
val initializers = kProperties.values.sortedBy { it.second }.map { it.first }
|
||||
// TODO: move to object for lazy initialization.
|
||||
irFile.addChild(kPropertiesField.apply {
|
||||
irFile.declarations.add(0, kPropertiesField.apply {
|
||||
initializer = IrExpressionBodyImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
context.createArrayOfExpression(kPropertyImplType, initializers, UNDEFINED_OFFSET, UNDEFINED_OFFSET))
|
||||
})
|
||||
|
||||
kPropertiesField.parent = irFile
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user