Conversation
…MyIface.impl by having all iface required methods setup in the implementation Ruby class to always dispatch to impl logic. also improves performance due dispatching directly to method_missing
…nless present we're keeping Iface.impl backwards compatible to override all instance methods by default (unless methods are specified or we introduced impl(false) to keep defaults) for proc-to-iface (functionak) impls implementing default methods makes no sense ... use cases such as Function#compose with a Ruby impl did not work previously
…impl using a block we're now add an internal "impl" method for each prescribed abstract interface method this is expected to resolve conflicting issues (e.g using Java 8 streams) such as #3475
Member
|
@kares can you think of any breakage this will cause? Your last sentence implies there might be breakage but do you actually know of any? |
Member
Author
|
@enebo only thing I can think of if users realize that these use |
Member
Member
|
Ok, this one seems fine to me and I think the impl is right. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
there are two ways Ruby interface implementations are being generated :
Iface.impl { |name, *args| }both of these add
method_missingto the Ruby class which leads to issues when there's a naming clash in the hierarchy (e.g.Kernel#testwithjava.util.function.Predicate#test). these are resolved by binding implemented interface methods on the implementing Ruby class - always executing the desired user provided bits (except where he wouldImplClass.class_eval { def test ... }the method of course).on the Java (codegen) side, under Java 8, this further revealed that static methods were unnecessarily being generated and that interface's default methods are always being overridden ...
Iface.implthe behaviour of implementing all methods (including defaults) was kept.impl(:foo, :bar)already allows for implementing method names to be specified and an additionalimpl(false)to generate just the minimum abstract method(s) required is introduced. new code also warns onimpl(:foo)when"foo"is not actually an interface method.java.util.function.Function#compose) to work correctly.all-in-all these changes should be welcoming by JI users - it might break compatibility in very corner cases but its usually for the best to review those.
resolves #3475