icerockdev / moko-kswift

Swift-friendly api generator for Kotlin/Native frameworks
https://moko.icerock.dev
Apache License 2.0
351 stars 21 forks source link

Internal sealed class are exported #35

Closed cl3m closed 2 years ago

cl3m commented 2 years ago

Internal sealed class are exported by kswift but won't be available in the library. Swift compilation failed because it can not find types.

internal sealed class Response<T> {
    data class Success<T>(val result: T) : Response<T>()
    data class Failure<T>(val error: String?) : Response<T>()
}
cl3m commented 2 years ago

Internal sealed class can be hidden with the @KSwiftExclude annotation but it does not work for the sub class.

sealed class Test {
    data class Exported(val value: Int) : Test()
    @KSwiftExclude // does not work, nor internal keyword
    internal data class Hidden(val value: Int) : Test()
}

Such class will make swift fail compilation as well.

Alex009 commented 2 years ago

will be available in 0.4.0

lammertw commented 1 year ago

Apparently this also doesn't work for sealed classes under another internal class. Example:

internal interface MyInterface {
    sealed class Test {} // still gets exported
}

Not sure if there is any way to fix that.