swiftlang / swift-java

Apache License 2.0
724 stars 27 forks source link

Java2Swift: `java.util.ArrayList` does not work with `JavaKitFunction` #128

Closed DougGregor closed 3 weeks ago

DougGregor commented 3 weeks ago

When bringing in java.util.ArrayList in a target that depends on JavaKitFunction, we end up with this ill-formed method:

  @JavaMethod
  public func toArray(_ arg0: JavaIntFunction<[JavaObject?]>?) -> [JavaObject?]

which produces this error:

error: type '[JavaObject?]' does not conform to protocol 'AnyJavaObject'

We need to realize when we are within a context where we must have a Java class, not its bridged value type, and use that Java class. This also means bringing java.lang.String and java.lang.Array into Swift as classes as well.