diff --git a/kmath-ast/src/jvmMain/kotlin/scientifik/kmath/asm/internal/AsmGenerator.kt b/kmath-ast/src/jvmMain/kotlin/scientifik/kmath/asm/internal/AsmGenerator.kt index f636fc289..d2568eb53 100644 --- a/kmath-ast/src/jvmMain/kotlin/scientifik/kmath/asm/internal/AsmGenerator.kt +++ b/kmath-ast/src/jvmMain/kotlin/scientifik/kmath/asm/internal/AsmGenerator.kt @@ -17,7 +17,6 @@ import scientifik.kmath.operations.Algebra * @param algebra the algebra the applied AsmExpressions use. * @param className the unique class name of new loaded class. */ -@Suppress("UNCHECKED_CAST") @PublishedApi internal class AsmGenerator @PublishedApi internal constructor( private val classOfT: Class<*>, @@ -45,6 +44,7 @@ internal class AsmGenerator @PublishedApi internal constructor( private lateinit var invokeMethodVisitor: MethodVisitor private var generatedInstance: FunctionalCompiledExpression? = null + @Suppress("UNCHECKED_CAST") fun getInstance(): FunctionalCompiledExpression { generatedInstance?.let { return it } @@ -101,15 +101,14 @@ internal class AsmGenerator @PublishedApi internal constructor( visitEnd() } - invokeMethodVisitor = visitMethod( + visitMethod( access = Opcodes.ACC_PUBLIC or Opcodes.ACC_FINAL, name = "invoke", descriptor = "(L$MAP_CLASS;)L$T_CLASS;", signature = "(L$MAP_CLASS;)L$T_CLASS;", exceptions = null - ) {} - - invokeMethodVisitor.run { + ) { + invokeMethodVisitor = this visitCode() val l0 = Label() visitLabel(l0) @@ -121,7 +120,7 @@ internal class AsmGenerator @PublishedApi internal constructor( visitLocalVariable( "this", "L$slashesClassName;", - T_CLASS, + null, l0, l1, invokeThisVar @@ -280,9 +279,7 @@ internal class AsmGenerator @PublishedApi internal constructor( invokeMethodVisitor.visitCheckCast(T_CLASS) } - internal fun loadStringConstant(string: String) { - invokeMethodVisitor.visitLdcInsn(string) - } + internal fun loadStringConstant(string: String): Unit = invokeMethodVisitor.visitLdcInsn(string) internal companion object { private val SIGNATURE_LETTERS: Map, String> by lazy {