[ 
https://issues.apache.org/jira/browse/SPARK-33285?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17245223#comment-17245223
 ] 

Yang Jie commented on SPARK-33285:
----------------------------------

{quote}Note that Scala 2.13 has a configurable warning mechanism, making it 
possible to hide some warnings: [https://github.com/scala/scala/pull/8373,] 
this can be combined with {{-Xfatal-warnings}} to enforce a warning-free build 
without actually fixing all warnings.
{quote}
 
But it seems that we can't suppress all compilation warnings, such as 
auto-application, which is different from eta-zero and eta-sam

 
{code:java}
def checkCanAutoApply(): Boolean = {
  if (!isPastTyper && !matchNullaryLoosely) {
    context.deprecationWarning(tree.pos, NoSymbol, s"Auto-application to `()` 
is deprecated. Supply the empty argument list `()` explicitly to invoke method 
${meth.decodedName},\n" +
                                                   s"or remove the empty 
argument list from its definition (Java-defined methods are exempt).\n"+
                                                   s"In Scala 3, an unapplied 
method like this will be eta-expanded into a function.", "2.13.3")
  }
  true
}
{code}
 
{code:java}
def warnEtaZero(): Boolean = {
  if (!settings.warnEtaZero) return true
  context.warning(tree.pos,
    s"""An unapplied 0-arity method was eta-expanded (due to the expected type 
$pt), rather than applied to `()`.
       |Write ${Apply(warnTree, Nil)} to invoke method ${meth.decodedName}, or 
change the expected type.""".stripMargin,
    WarningCategory.LintEtaZero)
  true
}

def warnEtaSam(): Boolean = {
  if (!settings.warnEtaSam) return true
  val sam = samOf(pt)
  val samClazz = sam.owner
  // TODO: we allow a Java class as a SAM type, whereas Java only allows the 
@FunctionalInterface on interfaces -- align?
  if (sam.exists && (!samClazz.hasFlag(JAVA) || samClazz.hasFlag(INTERFACE)) && 
!samClazz.hasAnnotation(definitions.FunctionalInterfaceClass))
    context.warning(tree.pos,
      s"""Eta-expansion performed to meet expected type $pt, which is 
SAM-equivalent to ${samToFunctionType(pt)},
         |even though $samClazz is not annotated with `@FunctionalInterface`;
         |to suppress warning, add the annotation or write out the equivalent 
function literal.""".stripMargin,
      WarningCategory.LintEtaSam)
  true
}
{code}

> Too many "Auto-application to `()` is deprecated."  related compilation 
> warnings
> --------------------------------------------------------------------------------
>
>                 Key: SPARK-33285
>                 URL: https://issues.apache.org/jira/browse/SPARK-33285
>             Project: Spark
>          Issue Type: Improvement
>          Components: Build
>    Affects Versions: 3.1.0
>            Reporter: Yang Jie
>            Priority: Minor
>
> There are too many  "Auto-application to `()` is deprecated." related 
> compilation warnings when compile with Scala 2.13 like
> {code:java}
> [WARNING] [Warn] 
> /spark-src/core/src/test/scala/org/apache/spark/PartitioningSuite.scala:246: 
> Auto-application to `()` is deprecated. Supply the empty argument list `()` 
> explicitly to invoke method stdev,
> 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.
> {code}
> A lot of them, but it's easy to fix.
> If there is a definition as follows:
> {code:java}
> Class Foo {
>    def bar(): Unit = {}
> }
> val foo = new Foo{code}
> Should be
> {code:java}
> foo.bar()
> {code}
> not
> {code:java}
> foo.bar {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to