Skip to content
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

Generated reverse route method should have empty parentheses () depending on routes file #10363

Closed
gakuzzzz opened this issue Jun 29, 2020 · 3 comments · Fixed by #10671
Closed

Comments

@gakuzzzz
Copy link

gakuzzzz commented Jun 29, 2020

Play Version

2.8.2

API

Scala

Operating System

Not related to this problem

JDK

Not related to this problem

Library Dependencies

non

Expected Behavior

No warning in Scala2.13.3.

Actual Behavior

  1. controller
package controllers

import javax.inject._
import play.api._
import play.api.mvc._

@Singleton
class HomeController @Inject()(val controllerComponents: ControllerComponents) extends BaseController {

  def index = Action { implicit request: Request[AnyContent] =>
    Ok("")
  }

  def redirect = Action { implicit request: Request[AnyContent] =>
    Redirect(routes.HomeController.index)
  }

}
  1. compile

Warning is displayed.

[warn] D:\workspace\example\app\controllers\HomeController.scala:15:36: Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method index,
[warn] or remove the empty argument list from its definition (Java-defined methods are exempt).
[warn] In Scala 3, an unapplied method like this will be eta-expanded into a function.
[warn]     Redirect(routes.HomeController.index)
[warn]                                    ^
[warn] one warning found

Related resources

@mkurz
Copy link
Member

mkurz commented Jun 29, 2020

I think you just need to change

Redirect(routes.HomeController.index)

to

Redirect(routes.HomeController.index())

However I think we also need to fix Play's routes generator as well: #10364

@gakuzzzz
Copy link
Author

Hi, @mkurz

Thanks, I think so too.

When the index was defined as def index() = Action{...}, we need to change to Redirect(routes.HomeController.index()).
However the index method has no side-effect. so it is defined as def index = Action{...}.
We expect that Play's routes generator generates no-parentheses method.

regards,

@triage-new-issues triage-new-issues bot removed the triage label Jul 6, 2020
@triage-new-issues triage-new-issues bot removed the triage label Jul 6, 2020
@mkurz mkurz added this to the 2.8.8 milestone Jan 25, 2021
@mkurz mkurz changed the title Routes what are generated by play has the warning 'auto-application ()' in Scala2.13.3 Generated reverse route method should have empty parentheses () depending on routes file Feb 1, 2021
@mkurz
Copy link
Member

mkurz commented Feb 1, 2021

Fix is here #10671

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants