Skip to content

Wrong rewrite of a partial function passed to a symbolic operator #20002

Closed
@OndrejSpanel

Description

@OndrejSpanel

Compiler version

3..4.1-RC2

Minimized code

Use -indent -rewrite on following code:

@main
def main: Unit = {

  object reactions {
    def += (f: PartialFunction[String, Unit]) = ???
  }

  reactions += {
    case a =>
    case b =>
  }
}

Output

@main
def main: Unit =

  object reactions:
    def += (f: PartialFunction[String, Unit]) = ???

  reactions += :
    case a =>
    case b =>

Compiling this results in following error:

C:\Dev\Sandbox\src\main\scala\Main.scala:7:16
expression expected but : found
reactions += :

Expectation

The output of "-indent", "-rewrite" should compile without errors

Note

This pattern is common when using Scala Swing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions