[Possible Bug?] Hey! Was messing around with Swift...
# swift-export
d
[Possible Bug?] Hey! Was messing around with Swift Export and found a really unusual behavior regarding enum classes. More info under this message 🙂
If I have a class like this:
Copy code
class Greeting {

    fun test(): String = "Test"
    fun type(): GreetingType = GreetingType.whats_UP
}

enum class GreetingType {
    HI,
    hello,
    whats_UP,
    Hey;
}
And try to fetch a
GreetingType
by calling
type()
, the app crashes. It doesn't matter what enum class value I'm returning, the crash always happens.
__externalRCRefUnsafe
in the generated
Shared.swift
file has a memory address that does not represent any of the memory addresses for the other enum class values, throwing a
fatalError()
(check screenshot) If I initialize a variable directly by referencing a enum class value then the crash doesn't happen:
val a = <http://org.example.com|org.example.com>.GreetingType.HI
This only happens when I try to get the value from a function. I created a really small repro using KMP Wizard, here's the link. Am I missing something here? I'm not sure if there's an actual bug or I'm just doing something silly which in turn causes the bug.
@Artem Olkov mentioning you so that you can be aware of this 😄
a
Yes, hi 🙂 Thanks for the report This is a known bug - https://youtrack.jetbrains.com/issue/KT-83730 Fix is already on the review and should be released with 2.4.0 🙂
blob sunglasses 3
K 2