I’m having a bit of trouble with Dokka on a Kotlin...
# dokka
I’m having a bit of trouble with Dokka on a Kotlin Multiplatform, multi-module project. Unfortunately the error message/stacktrace are pretty vague and I haven’t really got much of a clue where to start, can anyone give me some pointers? More in the thread…
The stack overflow is on
seems to happen on any of the
commands (I’ve tried HTML and GFM)
and using 1.6.21
I have 5 modules, and only one of them throws like this, the other modules’
commands work fine
I figured out what was wrong. we had the following
Copy code
public expect class WeakReference<T : Any>(referred: T) {
    public fun get(): T?
implementations that looked like this: iOS:
Copy code
import kotlin.native.ref.WeakReference

public actual typealias WeakReference<T> = WeakReference<T>
Copy code
import java.lang.ref.WeakReference

public actual typealias WeakReference<T> = WeakReference<T>
The solution was to use an import alias, like so:
Copy code
// android
import java.lang.ref.WeakReference as JvmWeakReference

public actual typealias WeakReference<T> = JvmWeakReference<T>

// ios
import kotlin.native.ref.WeakReference as NativeWeakReference

public actual typealias WeakReference<T> = NativeWeakReference<T>
Did this only make Dokka fail? Or did the compiler fail before that? I'm surprised it even compiled!
This is https://github.com/Kotlin/dokka/issues/2281 I suppose you did not configure your project correctly. You can take a look at my sample project with
typealias WeakReference
I am actually the author of the Github issue. This only happens in Dokka and compiles fine when Dokka is disabled.
I agree it’s not the best code but it would be great if Dokka didn’t crash with a hard-to-find stackoverflow error. Still need to provide a reproducer for the issue as it doesn’t seem to be happening in isolation.