Skip to content

Unable to use functional interface as a SAM because of Scala's "concrete beats deferred" rule #11362

Open
@retronym

Description

@retronym
package p1;

public class Test {
    @FunctionalInterface
    public static interface A {
        String foo();
    }
    @FunctionalInterface
    public static interface B extends A {
        default String bar() { return bar(); };
        String foo();
    }
    @FunctionalInterface
    public static interface C extends B {
        @Override String bar();
        default String foo() { return "C"; }
    }
}
scala> println(samOf(typeOf[p1.Test.C]))
<none>

It isn't clear to me that the current approach of treating Java default methods as concrete from the perspective of the Scala type system is the right approach. (We already have a different mechanism to mark them: Flag.JAVA_DEFAULT_METHOD), which we can use in override checks, etc.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions