Skip to content

nullary methods(methods that take no arguments) that return lambdas depend on whether an empty pair of parens are used #9327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
scabug opened this issue May 25, 2015 · 2 comments
Milestone

Comments

@scabug
Copy link

scabug commented May 25, 2015

This line compiles

class B{ def b  :(Char)=>Unit = ((c:Char) => ()) };  val f:(Char)=>Unit = new B().b

While this line wont

class B{ def b():(Char)=>Unit = ((c:Char) => ()) };  val f:(Char)=>Unit = new B().b

Because B.b will be thought to return a ()=> (Char)=> () instead of a (Char)=> (). This behavior is not present when the return types are not lambdas, and it is masked with the caller uses parens, as that executes the returned lambda, which then returns the expected one.

@scabug
Copy link
Author

scabug commented May 25, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9327?orig=1
Reporter: mako yass (makoConstruct)
Affected Versions: 2.11.4, 2.11.6
Duplicates #7187

@som-snytt
Copy link

Fixed in the linked ticket, but life goes on and 2.13.8 warns

       warning: Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method b,
       or remove the empty argument list from its definition (Java-defined methods are exempt).
       In Scala 3, an unapplied method like this will be eta-expanded into a function.

@SethTisue SethTisue added this to the 2.13.0 milestone Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants