File tree Expand file tree Collapse file tree 3 files changed +17
-34
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +17
-34
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ import StdNames._
2323import NameKinds .DefaultGetterName
2424import ProtoTypes ._
2525import Inferencing ._
26- import UnusedUtil ._
2726
2827import collection .mutable
2928import config .Printers .{overload , typr , unapp }
@@ -1542,6 +1541,23 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
15421541 harmonizedElems
15431542 }
15441543
1544+ /** Transforms the tree into a its default tree.
1545+ * Performed to shrink the tree that is known to be erased later.
1546+ */
1547+ protected def normalizeUnusedExpr (tree : Tree , msg : String )(implicit ctx : Context ): Tree = {
1548+ if (! isPureExpr(tree))
1549+ ctx.warning(msg + " This expression will not be evaluated." , tree.pos)
1550+ defaultValue(tree.tpe)
1551+ }
1552+
1553+ /** Transforms the rhs tree into a its default tree if it is in an `unused` val/def.
1554+ * Performed to shrink the tree that is known to be erased later.
1555+ */
1556+ protected def normalizeUnusedRhs (rhs : Tree , sym : Symbol )(implicit ctx : Context ) = {
1557+ if (sym.is(Unused ) && rhs.tpe.exists) normalizeUnusedExpr(rhs, " Expression is on the RHS of an `unused` " + sym.showKind + " . " )
1558+ else rhs
1559+ }
1560+
15451561 /** If all `types` are numeric value types, and they are not all the same type,
15461562 * pick a common numeric supertype and widen any constant types in `tpes` to it.
15471563 * If the resulting types are all the same, return them instead of the original ones.
Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ import dotty.tools.dotc.transform.Erasure.Boxing
2929import util .Positions ._
3030import util .common ._
3131import util .{Property , SourcePosition }
32- import UnusedUtil ._
3332
3433import collection .mutable
3534import annotation .tailrec
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments