icerockdev / moko-kswift

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

Xcode warnings on generated code: forced cast always succeeds #60

Closed sebj closed 5 months ago

sebj commented 1 year ago

I believe I'm experiencing the same issue as #46, even though this is supposed to be fixed in 0.6.0.

I'm seeing 125 Xcode warnings inside my generated Swift file for "forced cast from '..' to '..' always succeeds, did you mean to use 'as'?". These all occur inside the sealed Swift property relating to Kotlin sealed classes, where the Swift enum case always has 1 parameter and the Kotlin sealed class does not use generics at all.

I believe this should fall into the logic mentioned in #46:

If the enum case has a parameter, and the return type is not generic, it does not need to be force-cast.

My environment:

hoc081098 commented 1 year ago

I have the same issue

heartsker commented 8 months ago

Faced same problem