Fix RTTI bugs. (#105)

This commit is contained in:
Nikolay Igotti
2016-12-01 15:08:08 +03:00
committed by GitHub
parent 71a8886856
commit fbf4db6428
3 changed files with 11 additions and 6 deletions
@@ -10,7 +10,11 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.*
internal val ClassDescriptor.implementedInterfaces: List<ClassDescriptor>
get() {
val superClassImplementedInterfaces = this.getSuperClassNotAny()?.implementedInterfaces ?: emptyList()
return (superClassImplementedInterfaces + this.getSuperInterfaces()).distinctBy { it.classId }
val superInterfaces = this.getSuperInterfaces()
val superInterfacesImplementedInterfaces = superInterfaces.flatMap { it.implementedInterfaces }
return (superClassImplementedInterfaces +
superInterfacesImplementedInterfaces +
superInterfaces).distinctBy { it.classId }
}
@@ -62,6 +66,7 @@ internal val ClassDescriptor.isArray: Boolean
internal val ClassDescriptor.isInterface: Boolean
get() = (this.kind == ClassKind.INTERFACE)
internal val CallableDescriptor.allValueParameters: List<ParameterDescriptor>
get() {
val constructorReceiver = if (this is ConstructorDescriptor) {
@@ -76,4 +81,4 @@ internal val CallableDescriptor.allValueParameters: List<ParameterDescriptor>
this.extensionReceiverParameter).filterNotNull()
return receivers + this.valueParameters
}
}
@@ -149,9 +149,9 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils {
val size = getInstanceSize(classType, className)
val superTypeOrNull = classDesc.getSuperClassNotAny()
val superType = if (superTypeOrNull != null) superTypeOrNull.llvmTypeInfoPtr
else NullPointer(runtime.typeInfoType)
val superTypeOrAny = classDesc.getSuperClassOrAny()
val superType = if (KotlinBuiltIns.isAny(classDesc)) NullPointer(runtime.typeInfoType)
else superTypeOrAny.llvmTypeInfoPtr
val interfaces = classDesc.implementedInterfaces.map { it.llvmTypeInfoPtr }
val interfacesPtr = staticData.placeGlobalConstArray("kintf:$className",
@@ -151,7 +151,7 @@ class ArrayList<E> private constructor(
override fun equals(other: Any?): Boolean {
//TODO: rethink instance checks, shall it be other is List<*>?
return other === this ||
(other is ArrayList<*>) && contentEquals(other)
(other is List<*>) && contentEquals(other)
}
override fun hashCode(): Int {