Skip to content

Commit aa53182

Browse files
committed
Add documentation
1 parent 6a40b84 commit aa53182

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

compiler/src/dotty/tools/dotc/typer/UnusedUtil.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,21 @@ import dotty.tools.dotc.core.Flags._
1212
*/
1313
object UnusedUtil {
1414

15+
/** Transforms the tree into a its default tree.
16+
* Performed to shrink the tree that is known to be erased later.
17+
*/
1518
def normalizeUnusedExpr(tree: Tree, msg: String)(implicit ctx: Context): Tree = {
1619
if (!isPureExpr(tree))
1720
ctx.warning(msg + "This expression will not be evaluated.", tree.pos)
1821
defaultValue(tree.tpe)
1922
}
2023

21-
def normalizeUnusedRhs(tree: Tree, sym: Symbol)(implicit ctx: Context) = {
22-
if (sym.is(Unused) && tree.tpe.exists) normalizeUnusedExpr(tree, "Expression is on the RHS of an `unused` " + sym.showKind + ". ")
23-
else tree
24+
/** Transforms the rhs tree into a its default tree if it is in an `unused` val/def.
25+
* Performed to shrink the tree that is known to be erased later.
26+
*/
27+
def normalizeUnusedRhs(rhs: Tree, sym: Symbol)(implicit ctx: Context) = {
28+
if (sym.is(Unused) && rhs.tpe.exists) normalizeUnusedExpr(rhs, "Expression is on the RHS of an `unused` " + sym.showKind + ". ")
29+
else rhs
2430
}
2531

2632
}

0 commit comments

Comments
 (0)