diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt index 067bbb0ae8e..266b7fa2c35 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt @@ -1229,9 +1229,10 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid //-------------------------------------------------------------------------// private fun genInstanceOf(obj: LLVMValueRef, type: KotlinType): LLVMValueRef { - val dstDescriptor = TypeUtils.getClassDescriptor(type) // Get class descriptor for dst type. + var dstDescriptor = TypeUtils.getClassDescriptor(type) // Get class descriptor for dst type. // Reified parameters are not yet supported. - assert(dstDescriptor != null) + if (dstDescriptor == null) return kTrue // Workaround for reified parameters + val dstTypeInfo = codegen.typeInfoValue(dstDescriptor!!) // Get TypeInfo for dst type. val srcObjInfoPtr = codegen.bitcast(codegen.kObjHeaderPtr, obj) // Cast src to ObjInfoPtr. val args = listOf(srcObjInfoPtr, dstTypeInfo) // Create arg list. diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionInlining.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionInlining.kt index 36c8867d9d0..69c96c54e11 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionInlining.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionInlining.kt @@ -11,10 +11,7 @@ import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrFunction import org.jetbrains.kotlin.ir.declarations.IrVariable import org.jetbrains.kotlin.ir.expressions.* -import org.jetbrains.kotlin.ir.expressions.impl.IrContainerExpressionBase -import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl -import org.jetbrains.kotlin.ir.expressions.impl.IrMemberAccessExpressionBase -import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl +import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.ir.util.DeepCopyIrTree import org.jetbrains.kotlin.ir.util.getArguments import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid @@ -87,9 +84,9 @@ internal class FunctionInlining(val context: Context): IrElementTransformerVoid( val result = super.visitCall(irCall) if (functionDeclaration == null) return result // Function is declared in another module. -// print("inline function ${currentFile!!.name} ") // TODO debug output -// print("function: ${currentFunction!!.descriptor.name} ") // TODO debug output -// println("call: ${functionDescriptor.name} ${irCall.startOffset}") // TODO debug output + print("file: ${currentFile!!.fileEntry.name} ") // TODO debug output + print("function: ${currentFunction!!.descriptor.name} ") // TODO debug output + println("call: ${functionDescriptor.name} ${irCall.startOffset}") // TODO debug output val copyFuncDeclaration = functionDeclaration.accept(DeepCopyIrTree(), // Create copy of the function. null) as IrFunction @@ -117,8 +114,10 @@ internal class FunctionInlining(val context: Context): IrElementTransformerVoid( override fun visitCall(expression: IrCall): IrExpression { val fqName = currentFile!!.packageFragmentDescriptor.fqName.asString() // TODO to be removed after stdlib compilation - if(fqName.contains("kotlin")) return super.visitCall(expression) // TODO to be removed after stdlib compilation - // if (currentFunction!!.descriptor.isInline) return super.visitCall(expression) // TODO workaround + // if(fqName.contains("kotlin")) return super.visitCall(expression) // TODO to be removed after stdlib compilation + val fileName = currentFile!!.fileEntry.name + if (fileName.contains("cinterop")) return super.visitCall(expression) + if (currentFunction!!.descriptor.isInline) return super.visitCall(expression) // TODO workaround val functionDescriptor = expression.descriptor as FunctionDescriptor if (functionDescriptor.isInline) return inlineFunction(expression) // Return newly created IrInlineBody instead of IrCall. @@ -246,7 +245,6 @@ internal class ParametersTransformer(val parameterToArgument: MutableList