vinivendra / Gryphon

The Swift to Kotlin translator.
https://vinivendra.github.io/Gryphon/
Other
607 stars 44 forks source link

Translate access modifiers for extensions #15

Open vinivendra opened 4 years ago

vinivendra commented 4 years ago

Currently (as of Swift 5.1.3) extensions don't include their access modifiers when their AST is dumped. This is an issue with the Swift compiler that stops Gryphon being able to translate access modifiers in extensions.

Fixing this issue would allow for extensions to be treated as basically any other declaration in the access modifier algorithm.

sgade commented 4 years ago

Does this issue include the fact that a static extension member is not added to the Companion object?

I mean something like this:

extension MyClass {
    static var myInstance: MyClass {
        return MyClass()
    }
}

which is translated to

internal val MyClass.myInstance: MyClass
  get() {
    return MyClass()
  }

where I'd expect

internal val MyClass.Companion.myInstance: MyClass
  get() {
    return MyClass()
  }
vinivendra commented 4 years ago

No, that's a whole other bug 😅 would you mind filing a new report?

It would probably be an easy fix; just translate variables the same way we translate functions.