Skip to content

SAM types + Overloading + Eta-expansion #4364

Closed
@allanrenucci

Description

@allanrenucci

The following code snippet fails to compile with Dotty. (Works with scalac)

class Test {
  def println(): Unit = ()
  def println(x: String): Unit = ()

  def foo(x: java.util.function.Consumer[String]) = 1
  foo(println(_))      // ok
  foo(x => println(x)) // ok
  foo(println)         // error
}
-- [E007] Type Mismatch Error: tests/allan/Test.scala:26:6 ---------------------
26 |  foo(println)
   |      ^^^^^^^
   |      found:    Unit
   |      required: java.util.function.Consumer[String]
   |      
one error found

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions