Skip to content

Commit

Permalink
Move methods from UnusedUtil to Applications
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Feb 15, 2018
1 parent ed50958 commit c040798
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 34 deletions.
18 changes: 17 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import StdNames._
import NameKinds.DefaultGetterName
import ProtoTypes._
import Inferencing._
import UnusedUtil._

import collection.mutable
import config.Printers.{overload, typr, unapp}
Expand Down Expand Up @@ -1542,6 +1541,23 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
harmonizedElems
}

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

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

/** If all `types` are numeric value types, and they are not all the same type,
* pick a common numeric supertype and widen any constant types in `tpes` to it.
* If the resulting types are all the same, return them instead of the original ones.
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import dotty.tools.dotc.transform.Erasure.Boxing
import util.Positions._
import util.common._
import util.{Property, SourcePosition}
import UnusedUtil._

import collection.mutable
import annotation.tailrec
Expand Down
32 changes: 0 additions & 32 deletions compiler/src/dotty/tools/dotc/typer/UnusedUtil.scala

This file was deleted.

0 comments on commit c040798

Please sign in to comment.