swiftlang/swift-java

[jextract] Handle ambiguous Swift methods not possible in Java

Opened this issue · 1 comments

If you try to wrap these functions

public init(throwing: Bool) throws {
  // ...  
}

public init?(doInit: Bool) {
  // ...
}

the current resulting Java functions would be:

public static MySwiftClass init(boolean throwing, SwiftArena swiftArena$) throws Exception
public static Optional<MySwiftClass> init(boolean doInit, SwiftArena swiftArena$)

which is not allowed in Java, since 'init(boolean, SwiftArena) is defined twice.

We should handle this, maybe adding the first parameterName as a suffix, or something else.

ktoso commented

Yeah, agreed with init<SuffixHere> Maybe we just promote parameter names into the method name to make it completely disambiguating if we ever hit a "conflict" like this.

You'll get into it with autocompletion easily enough still after all