From 56b72784d4f29bfd0b6cfdfec6fe9db20197d9f6 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Tue, 9 Apr 2024 21:42:37 +0200 Subject: [PATCH] Rewrite `actual IntStack` using `class` instead of `typealias` If `IntStack` expanded to `IntArrayList`, it contains ambiguous actual functions: `push(int)` and `push(Integer)` (j2k interaction works a bit confused). K2 treats them as an error. Unfortunately, fixing a third-party library with `IntArrayList` (fastutil) is rather complicated, especially considering the library uses code generation. Fortunately, `IntStack` can be rewritten with just a class. See also https://youtrack.jetbrains.com/issue/KT-66723 --- src/jvmMain/kotlin/CommonDefsImplJvm.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/jvmMain/kotlin/CommonDefsImplJvm.kt b/src/jvmMain/kotlin/CommonDefsImplJvm.kt index b7341e7..aba7f02 100644 --- a/src/jvmMain/kotlin/CommonDefsImplJvm.kt +++ b/src/jvmMain/kotlin/CommonDefsImplJvm.kt @@ -1,15 +1,21 @@ package org.intellij.markdown.html import it.unimi.dsi.fastutil.ints.IntArrayList -import it.unimi.dsi.fastutil.ints.IntStack import java.net.URLEncoder -import java.util.Stack actual class BitSet actual constructor(size: Int): java.util.BitSet(size){ actual val size = size() } -actual typealias IntStack = IntArrayList +actual class IntStack { + private val intArrayList = IntArrayList() + + actual fun push(e: Int) = intArrayList.push(e) + + actual fun pop(): Int = intArrayList.popInt() + + actual fun isEmpty(): Boolean = intArrayList.isEmpty +} private const val PUNCTUATION_MASK: Int = (1 shl Character.DASH_PUNCTUATION.toInt()) or (1 shl Character.START_PUNCTUATION.toInt()) or