File tree 3 files changed +17
-34
lines changed
compiler/src/dotty/tools/dotc/typer
3 files changed +17
-34
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,6 @@ import NameKinds.DefaultGetterName
24
24
import ProtoTypes ._
25
25
import EtaExpansion ._
26
26
import Inferencing ._
27
- import UnusedUtil ._
28
27
29
28
import collection .mutable
30
29
import config .Printers .{overload , typr , unapp }
@@ -1540,6 +1539,23 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1540
1539
harmonizedElems
1541
1540
}
1542
1541
1542
+ /** Transforms the tree into a its default tree.
1543
+ * Performed to shrink the tree that is known to be erased later.
1544
+ */
1545
+ protected def normalizeUnusedExpr (tree : Tree , msg : String )(implicit ctx : Context ): Tree = {
1546
+ if (! isPureExpr(tree))
1547
+ ctx.warning(msg + " This expression will not be evaluated." , tree.pos)
1548
+ defaultValue(tree.tpe)
1549
+ }
1550
+
1551
+ /** Transforms the rhs tree into a its default tree if it is in an `unused` val/def.
1552
+ * Performed to shrink the tree that is known to be erased later.
1553
+ */
1554
+ protected def normalizeUnusedRhs (rhs : Tree , sym : Symbol )(implicit ctx : Context ) = {
1555
+ if (sym.is(Unused ) && rhs.tpe.exists) normalizeUnusedExpr(rhs, " Expression is on the RHS of an `unused` " + sym.showKind + " . " )
1556
+ else rhs
1557
+ }
1558
+
1543
1559
/** If all `types` are numeric value types, and they are not all the same type,
1544
1560
* pick a common numeric supertype and widen any constant types in `tpes` to it.
1545
1561
* 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
29
29
import util .Positions ._
30
30
import util .common ._
31
31
import util .{Property , SourcePosition }
32
- import UnusedUtil ._
33
32
34
33
import collection .mutable
35
34
import annotation .tailrec
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments