Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method fetch,

3k Views Asked by At

an interesting behaviour in the Scala compiler, prepared queries that use the “IN” operator will require special binding at compile time, called ListValue.

trait InSelectPreparedExamples extends db.Connector {

  lazy val selectInExample = db.entries.select.where(_.car in ?).prepareAsync()

  // This is a select * query, selecting the entire record
  def selectFromList(values: List[UUID]): Future[List[CarMetric]] = {
    selectInExample.flatMap(_.bind(ListValue(values)).fetch)
  }

  // We can use also use a vargargs style method call to achieve the same goal.  
  def selectFromArgs(args: UUID*): Future[List[CarMetric]] = {
    selectInExample.flatMap(_.bind(ListValue(args: _*)).fetch)
  }
}

when i use this ListValue i have got warn

**
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]     selectInExample.flatMap(_.bind(ListValue(values)).fetch())
[warn]                                   ^

scalaVersion := "2.13.4" libraryDependencies += "com.outworkers" %% "phantom-dsl" % "2.59.0"

how can fix it ?

1

There are 1 best solutions below

0
ayush On

In Scala 2.12 and below the following syntax was valid without any warnings

def test(): A = ???

test // is automatically expanded to test()

However from Scala 2.13 this gives a warning

Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method test

And in Scala 3 that syntax would be illegal.

In your case the phantom-dsl library has a class with methods with empty parameter list - https://github.com/outworkers/phantom/blob/v2.59.0/phantom-dsl/src/main/scala/com/outworkers/phantom/builder/primitives/Primitives.scala#L166

once they fix the bug you already reported the warnings should be gone.