java.interop
java.interop copied to clipboard
Support binding types with unresolved interfaces
Context: https://github.com/xamarin/java.interop/issues/358#issuecomment-411554871
Imagine the following:
public interface Fooable {
}
public class Foo implements Fooable {
}
Further imagine that Foo and Fooable are in separate foo.jar and fooable.jar files, and we attempt to bind only foo.jar.
Should this work?
Offhand, I can't think of any reason why it shouldn't be supportable.
Does this work? No. As a specific example, consider recyclerview-v7-28.0.0-beta01.aar: android.support.v7.widget.RecyclerView is a non-abstract type which implements the interface android.support.v4.view.ScrollingView, which cannot be resolved (as it's in a different .jar file). The RecyclerView type is not bound.
There are four scenarios to consider:
Non-abstract Foo and resolvable Fooable: This is what we currently require.
That said, Fooable need not be a public type! If it's a Kotlin internal type or a Java "package-private" type, then Fooable should not be bound. Foo still needs to declare all of the methods from Fooable.
Non-abstract Foo and unresolvable Fooable: We don't need to resolve Fooable, and can skip it. The binding for Foo will mirror Foo.
abstract Foo and resolvable Fooable: We need to"re-declare" all of Fooables methods into the binding of Foo, just as we normally do. That said, Fooable need not be a public type! If it's a Kotlin internal type or a Java "package-private" type, then Fooable should not be bound. Foo still needs to declare all of the methods from Fooable.
abstract Foo and unresolvable Fooable: This is an error. See: https://github.com/xamarin/java.interop/issues/371#issuecomment-438690309