Skip to content

Interface methods that another interface provides a default implementation for shouldn't be made into class abstract methods #1264

Open
@jpobst

Description

@jpobst

Context: kotlin.collections.AbstractList

Imagine we have an interface with a method, and another interface that implements that interface and provides a default implementation:

package java.util;

public interface SequencedCollection {
  SequencedCollection reverse ();
}

public interface List implements SequencedCollection {
  default SequencedCollection reversed() { ... }
}

If we have a class that implements List and does not provide its own implementation of reversed, when generator loops through all implemented interfaces, it will make an abstract Reverse method because it cannot detect that another interface provides a compatible default method.

// java
public abstract class AbstractList implements SequencedCollection { ... }

// csharp
public abstract class AbstractList : ISequencedCollection {
  public abstract ISequencedCollection Reversed ();
}

This causes issues for any bound Java class that inherits AbstractList, as they are expected to provide a Reversed method, when they don't provide one in the Java implementation.

AndroidX.Paging.ItemSnapshotList.cs(21,30): error CS0534: 'ItemSnapshotList' does not implement inherited abstract 
member 'AbstractList.Reversed()'

This issue is made worse by the fact it cannot be fixed with any existing metadata.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugComponent does not function as intendedgeneratorIssues binding a Java library (generator, class-parse, etc.)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions