Skip to content

wrong you can simply leave out the trailing _ message #23281

Open
@xuwei-k

Description

@xuwei-k

Compiler version

  • 3.7.0
  • 3.7.1-RC2

Minimized example

Welcome to Scala 3.7.1-RC2 (21.0.7, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                             
scala> trait A[B] { def f(x: String): B }
// defined trait A
                                                                                                                                             
scala> case class C(value: String)
// defined case class C
                                                                                                                                             
scala> val x: A[C] = C.apply _
1 warning found
-- Warning: --------------------------------------------------------------------
1 |val x: A[C] = C.apply _
  |              ^^^^^^^^^
  |              The syntax `<function> _` is no longer supported;
  |              you can simply leave out the trailing ` _`
val x: A[C] = Lambda/0x00000003015984c8@1d6a22dd
                                                                                                                                             
scala> val x: A[C] = C.apply
1 warning found
-- Warning: --------------------------------------------------------------------
1 |val x: A[C] = C.apply
  |              ^^^^^^^
  |method apply is eta-expanded even though A[C] does not have the @FunctionalInterface annotation.
val x: A[C] = Lambda/0x00000003015c1400@68a94e58

Why this Error/Warning was not helpful

compiler report another warning if remove _

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:reportingError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions