Skip to content

Processing SAM with overridden methods of java.lang.Object fails #7359

@neshkeev

Description

@neshkeev

Dotty fails to process @FunctionalInterface objects when they contain overridden public methods of java.lang.Object, but javadoc states:

If an interface declares an abstract method overriding one of the public methods of java.lang.Object, that also does not count toward the interface's abstract method count

minimized code

val comp : java.util.Comparator[Int] = (x, y) => -1
println(comp.compare(1,2))

fails with

-- [E081] Syntax Error: MySam.scala:10:46 --------------------------------------
10 |      val comp : java.util.Comparator[Int] = (x, y) => -1
   |                                              ^
   |                          Missing parameter type
   |                          
   |                          I could not infer the type of the parameter x.
-- [E081] Syntax Error: MySam.scala:10:49 --------------------------------------
10 |      val comp : java.util.Comparator[Int] = (x, y) => -1
   |                                                 ^
   |                          Missing parameter type
   |                          
   |                          I could not infer the type of the parameter y.
two errors found

expectation

The code above should print -1 to the standard output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions