Skip to content

wrap-java: Optional convenience methods can fail to compile when a parameter shadows the method name #945

Open

Description

@teamhimeh

Problem

Optional convenience methods generated by wrap-java invoke the original method without a receiver. A parameter can therefore shadow that method and make the generated Swift fail to compile.

Example

This Java declaration:

public OptionalLong arg0(OptionalLong value) { return value; }

produces a Swift convenience method whose argument is also named arg0:

open func arg0Optional(_ arg0: Int64?) -> Int64? {
  Optional(javaOptional: arg0(arg0.toJavaOptional()))
}

The body attempts to call the Optional argument as a function instead of calling the original method.

Reference workaround implementation: qoncept#8

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions