Skip to content

Commit 95fb46b

Browse files
committed
WIP
1 parent 183266d commit 95fb46b

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

compiler/src/dotty/tools/dotc/decompiler/DecompilationPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class DecompilationPrinter extends Phase {
3939
val unit = ctx.compilationUnit
4040

4141
out.println(s"/** Decompiled from $unit */")
42-
TastyImpl.showSourceCode.showTree(unit.tpdTree)(ctx)
42+
out.print(TastyImpl.showSourceCode.showTree(unit.tpdTree)(ctx))
4343

4444
if (ctx.settings.printTasty.value) {
4545
out.println("/*")

library/src/scala/tasty/util/ShowSourceCode.scala

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
2929

3030
def result(): String = sb.result()
3131

32-
def lineBreak: String = "\n" + (" " * indent)
32+
def lineBreak(): String = "\n" + (" " * indent)
3333

3434
def printTree(tree: Tree): Buffer = tree match {
3535
case tree @ PackageClause(Term.Ident(name), stats) =>
@@ -39,14 +39,14 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
3939
}
4040

4141
if (name == "<empty>") {
42-
printTrees(stats1, lineBreak)
42+
printTrees(stats1, lineBreak())
4343
} else {
4444
this += "package " += name += " {"
4545
indented {
46-
this += lineBreak
47-
printTrees(stats1, lineBreak)
46+
this += lineBreak()
47+
printTrees(stats1, lineBreak())
4848
}
49-
this += lineBreak += "}" += lineBreak
49+
this += lineBreak() += "}" += lineBreak()
5050
}
5151

5252
case Import(expr, selectors) =>
@@ -112,10 +112,10 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
112112
if (stats1.nonEmpty) {
113113
this += " {"
114114
indented {
115-
this += lineBreak
116-
printTrees(stats1, lineBreak)
115+
this += lineBreak()
116+
printTrees(stats1, lineBreak())
117117
}
118-
this += lineBreak += "}"
118+
this += lineBreak() += "}"
119119
}
120120
this
121121

@@ -244,26 +244,26 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
244244
this += "{"
245245
indented {
246246
if (!stats.isEmpty) {
247-
this += lineBreak
248-
printTrees(stats, lineBreak)
247+
this += lineBreak()
248+
printTrees(stats, lineBreak())
249249
}
250-
this += lineBreak
250+
this += lineBreak()
251251
printTree(expr)
252252
}
253-
this += lineBreak += "}"
253+
this += lineBreak() += "}"
254254
}
255255

256256
case Term.Inlined(call, bindings, expansion) =>
257257
sb.append("{ // inlined")
258258
indented {
259259
if (!bindings.isEmpty) {
260-
this += lineBreak
261-
printTrees(bindings, lineBreak)
260+
this += lineBreak()
261+
printTrees(bindings, lineBreak())
262262
}
263-
this += lineBreak
263+
this += lineBreak()
264264
printTree(expansion)
265265
}
266-
this += lineBreak += "}"
266+
this += lineBreak() += "}"
267267

268268
case Term.Lambda(meth, tpt) =>
269269
// Printed in Term.Block branch
@@ -281,17 +281,17 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
281281
printTree(selector)
282282
this += " match {"
283283
indented {
284-
this += lineBreak
285-
printCases(cases, lineBreak)
284+
this += lineBreak()
285+
printCases(cases, lineBreak())
286286
}
287-
this += lineBreak += "}"
287+
this += lineBreak() += "}"
288288

289289
case Term.Try(body, cases, finallyOpt) =>
290290
this += "try "
291291
printTree(body)
292292
if (cases.nonEmpty) {
293293
this += " catch "
294-
printCases(cases, lineBreak)
294+
printCases(cases, lineBreak())
295295
}
296296
finallyOpt match {
297297
case Some(t) =>
@@ -466,7 +466,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
466466
}
467467
this += " =>"
468468
indented {
469-
this += lineBreak
469+
this += lineBreak()
470470
printTree(body)
471471
}
472472
this
@@ -540,10 +540,10 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
540540
printTypeTree(tpt)
541541
this += " {"
542542
indented {
543-
this += lineBreak
543+
this += lineBreak()
544544
printTrees(refinements, "; ")
545545
}
546-
this += lineBreak += "}"
546+
this += lineBreak() += "}"
547547

548548
case TypeTree.Applied(tpt, args) =>
549549
printTypeTree(tpt)

0 commit comments

Comments
 (0)