Skip to content

proc to interface inconsistency with multiple args #9424

@kares

Description

@kares

Normally when JRuby encounters a functional interface with (the abstract method having) multiple parameters, the block receives all of them or the ones from the left e.g.

> { one: 1 }.to_java.forEach { |arg, val| puts arg }
one
=> nil
> { one: 1 }.to_java.forEach { |arg| puts arg }
one
=> nil

This behavior isn't consistent with a functional interface that includes an overload for the abstract interface method e.g.

  @FunctionalInterface
  public interface TwoArgWriter {

      void write(String label, java.io.File file);

      default void write(java.io.File file) {
          write("default-label", file);
      }
}

in this case the current behavior (in 9.4 - 10.0.5.0) is that the generated implementation ends up re-defining the default method as the implementation, the { |arg| ... } form will end up receiving the (second) File argument as the sole argument.

AI generated full reproducer: https://gist.github.com/kares/19b7e9aa8781eb4abf572d203642c980

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions