aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2017-02-18 23:58:49 +0100
committerGuillaume Martres <smarter@ubuntu.com>2017-02-19 00:00:19 +0100
commit5b330f1fea7a4c7ad3a33c237e99cc31fabfba59 (patch)
tree73a88e3b385f850fa108e7a4099979336c78513d /compiler/src/dotty/tools/dotc/typer/ImportInfo.scala
parent42e112b92a526bb9352febb14d8af48138bcfb87 (diff)
downloaddotty-5b330f1fea7a4c7ad3a33c237e99cc31fabfba59.tar.gz
dotty-5b330f1fea7a4c7ad3a33c237e99cc31fabfba59.tar.bz2
dotty-5b330f1fea7a4c7ad3a33c237e99cc31fabfba59.zip
ImportInfo: removed ctx parameter from constructor
ImportInfo#toString required the ctx parameter,so it was replaced by ImportInfo#toText.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/ImportInfo.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/typer/ImportInfo.scala35
1 files changed, 17 insertions, 18 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala b/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala
index 3ba610ef2..3bee0bbe8 100644
--- a/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala
+++ b/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala
@@ -5,6 +5,7 @@ package typer
import ast.{tpd, untpd}
import ast.Trees._
import core._
+import printing.{Printer, Showable}
import util.SimpleMap
import Symbols._, Names._, Denotations._, Types._, Contexts._, StdNames._, Flags._
import Decorators.StringInterpolators
@@ -28,7 +29,7 @@ object ImportInfo {
* scala.Predef or dotty.DottyPredef in the start context, false otherwise.
*/
class ImportInfo(symf: Context => Symbol, val selectors: List[untpd.Tree],
- symNameOpt: Option[TermName], val isRootImport: Boolean = false)(implicit ctx: Context) {
+ symNameOpt: Option[TermName], val isRootImport: Boolean = false) extends Showable {
// Dotty deviation: we cannot use a lazy val here for the same reason
// that we cannot use one for `DottyPredefModuleRef`.
@@ -91,7 +92,7 @@ class ImportInfo(symf: Context => Symbol, val selectors: List[untpd.Tree],
}
/** The implicit references imported by this import clause */
- def importedImplicits: List[TermRef] = {
+ def importedImplicits(implicit ctx: Context): List[TermRef] = {
val pre = site
if (isWildcardImport) {
val refs = pre.implicitMembers
@@ -115,23 +116,21 @@ class ImportInfo(symf: Context => Symbol, val selectors: List[untpd.Tree],
* override import Predef.{any2stringAdd => _, StringAdd => _, _} // disables String +
* override import java.lang.{} // disables all imports
*/
- lazy val unimported: Symbol = {
- lazy val sym = site.termSymbol
- def maybeShadowsRoot = symNameOpt match {
- case Some(symName) => defn.ShadowableImportNames.contains(symName)
- case None => false
+ def unimported(implicit ctx: Context): Symbol = {
+ if (myUnimported == null) {
+ lazy val sym = site.termSymbol
+ def maybeShadowsRoot = symNameOpt match {
+ case Some(symName) => defn.ShadowableImportNames.contains(symName)
+ case None => false
+ }
+ myUnimported =
+ if (maybeShadowsRoot && defn.RootImportTypes.exists(_.symbol == sym)) sym
+ else NoSymbol
+ assert(myUnimported != null)
}
- if (maybeShadowsRoot && defn.RootImportTypes.exists(_.symbol == sym)) sym
- else NoSymbol
+ myUnimported
}
+ private[this] var myUnimported: Symbol = _
- override def toString = {
- val siteStr = site.show
- val exprStr = if (siteStr endsWith ".type") siteStr dropRight 5 else siteStr
- val selectorStr = selectors match {
- case Ident(name) :: Nil => name.show
- case _ => "{...}"
- }
- i"import $exprStr.$selectorStr"
- }
+ def toText(printer: Printer) = printer.toText(this)
}