Skip to content

Confusing pretty print for method call on if expression #5997

Closed
@fhackett

Description

@fhackett
import quoted.Toolbox.Default._
val v = '{ (if true then Some(1) else None).map(v => v+1) }
v.show

will output (in REPL, Dotty 0.12.0):

val res0: String = if (true) scala.Some.apply[scala.Int](1) else scala.None.map[scala.Int](((v: scala.Int) => v.+(1)))
...

The confusing part is scala.None.map[scala.Int](..., which unless closely inspected suggests that we are calling None.map instead of (if ...).map.

Perhaps adding brackets around if expressions that are in this situation (the LHS of a method call) might help?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions