Skip to content

Commit

Permalink
Rewrite actual IntStack using class instead of typealias
Browse files Browse the repository at this point in the history
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
  • Loading branch information
KvanTTT committed Apr 9, 2024
1 parent 0b6f8f6 commit 56b7278
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/jvmMain/kotlin/CommonDefsImplJvm.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 56b7278

Please sign in to comment.