Skip to content

Commit

Permalink
Print owner of bind symbol with -Yprint-debug-owners (#16854)
Browse files Browse the repository at this point in the history
Compiling with `-Yprint-debug-owners` now prints the owners of `Bind`
trees.

#### Before 
```scala
class Foo() extends Object() {
  [owner = class Foo]def fooImpl: Int =
    1:Int match {
      case x @ y @ _:Int => 0
  }
}
```


#### After
```scala
class Foo() extends Object() {
  [owner = class Foo]def fooImpl: Int =
    1:Int match {
      case [owner = method fooImpl]x @ [owner = method fooImpl]y @ _:Int => 0
    }
}
```
  • Loading branch information
nicolasstucki authored Feb 8, 2023
2 parents ed35fef + 5fb2766 commit 6183cde
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
if (lo eq hi) && alias.isEmpty then optText(lo)(" = " ~ _)
else optText(lo)(" >: " ~ _) ~ optText(hi)(" <: " ~ _) ~ optText(alias)(" = " ~ _)
case bind @ Bind(name, body) =>
keywordText("given ").provided(tree.symbol.isOneOf(GivenOrImplicit) && !homogenizedView) ~ // Used for scala.quoted.Type in quote patterns (not pickled)
toTextOwner(bind) ~ keywordText("given ").provided(tree.symbol.isOneOf(GivenOrImplicit) && !homogenizedView) ~ // Used for scala.quoted.Type in quote patterns (not pickled)
changePrec(InfixPrec) { nameIdText(bind) ~ " @ " ~ toText(body) }
case Alternative(trees) =>
changePrec(OrPrec) { toText(trees, " | ") }
Expand Down

0 comments on commit 6183cde

Please sign in to comment.