aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r--src/dotty/tools/dotc/core/Constants.scala3
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala7
-rw-r--r--src/dotty/tools/dotc/core/Decorators.scala3
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala3
-rw-r--r--src/dotty/tools/dotc/core/Flags.scala5
-rw-r--r--src/dotty/tools/dotc/core/Names.scala6
-rw-r--r--src/dotty/tools/dotc/core/Scopes.scala3
-rw-r--r--src/dotty/tools/dotc/core/Symbols.scala3
-rw-r--r--src/dotty/tools/dotc/core/Trees.scala16
-rw-r--r--src/dotty/tools/dotc/core/Types.scala3
-rw-r--r--src/dotty/tools/dotc/core/UntypedTrees.scala2
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala5
12 files changed, 34 insertions, 25 deletions
diff --git a/src/dotty/tools/dotc/core/Constants.scala b/src/dotty/tools/dotc/core/Constants.scala
index cdfb62a18..b2949aae7 100644
--- a/src/dotty/tools/dotc/core/Constants.scala
+++ b/src/dotty/tools/dotc/core/Constants.scala
@@ -2,6 +2,7 @@ package dotty.tools.dotc
package core
import Types._, Symbols._, Contexts._
+import printing.Printer
object Constants {
@@ -189,7 +190,7 @@ object Constants {
def stringValue: String = value.toString
- def toText(implicit ctx: Context) = ctx.toText(this)
+ def toText(printer: Printer) = printer.toText(this)
def typeValue: Type = value.asInstanceOf[Type]
def symbolValue: Symbol = value.asInstanceOf[Symbol]
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index e6bd5a843..d29f8834d 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -8,13 +8,14 @@ import Names._
import Phases._
import Types._
import Symbols._
-import TypeComparers._, printing.Printers._, NameOps._, SymDenotations._, util.Positions._
+import TypeComparers._, NameOps._, SymDenotations._, util.Positions._
import TypedTrees.tpd._, util.FreshNameCreator
import config.Settings._
import config.ScalaSettings
import reporting._
import collection.mutable
import collection.immutable.BitSet
+import printing._
import config.{Settings, Platform, JavaPlatform}
import language.implicitConversions
@@ -43,7 +44,7 @@ object Contexts {
with Substituters
with TypeOps
with Phases
- with printing.Printers
+ with Printers
with Symbols
with SymDenotations
with Reporting
@@ -378,7 +379,7 @@ object Contexts {
object Context {
/** Implicit conversion that injects all printer operations into a context */
- implicit def toPrinter(ctx: Context) = ctx.printer(ctx)
+ implicit def toPrinter(ctx: Context) = ctx.printer
/** implicit conversion that injects all ContextBase members into a context */
implicit def toBase(ctx: Context): ContextBase = ctx.base
diff --git a/src/dotty/tools/dotc/core/Decorators.scala b/src/dotty/tools/dotc/core/Decorators.scala
index 2f91aa59a..5e2da43e5 100644
--- a/src/dotty/tools/dotc/core/Decorators.scala
+++ b/src/dotty/tools/dotc/core/Decorators.scala
@@ -3,7 +3,7 @@ package core
import annotation.tailrec
import Symbols._
-import Contexts._, Names._, Phases._, printing.Texts._
+import Contexts._, Names._, Phases._, printing.Texts._, printing.Printer
/** This object provides useful implicit decorators for types defined elsewhere */
object Decorators {
@@ -14,6 +14,7 @@ object Decorators {
def toTermName: TermName = termName(s)
def toEncodedTypeName = encodedTypeName(s)
def toEncodedTermName = encodedTermName(s)
+ def toText(printer: Printer): Text = Str(s)
}
/** Implements a findSymbol method on iterators of Symbols that
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index e30e230b1..97b25be00 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -10,6 +10,7 @@ import Symbols.NoSymbol
import Symbols._
import Types._, Periods._, Flags._, Transformers._
import printing.Texts._
+import printing.Printer
import io.AbstractFile
import Decorators.SymbolIteratorDecorator
@@ -288,7 +289,7 @@ object Denotations {
}
}
- def toText(implicit ctx: Context): Text = ctx.toText(this)
+ def toText(printer: Printer): Text = printer.toText(this)
}
/** An overloaded denotation consisting of the alternatives of both given denotations.
diff --git a/src/dotty/tools/dotc/core/Flags.scala b/src/dotty/tools/dotc/core/Flags.scala
index 726b13af9..f22c2a0f2 100644
--- a/src/dotty/tools/dotc/core/Flags.scala
+++ b/src/dotty/tools/dotc/core/Flags.scala
@@ -362,7 +362,7 @@ object Flags {
/** Flags representing source modifiers */
final val ModifierFlags =
commonFlags(Private, Protected, Abstract, Final,
- Sealed, Case, Implicit, AbsOverride, Lazy)
+ Sealed, Case, Implicit, Override, AbsOverride, Lazy)
/** Flags representing access rights */
final val AccessFlags = Private | Protected | Local
@@ -434,6 +434,9 @@ object Flags {
/** Labeled private[this] */
final val PrivateLocal = allOf(Private, Local)
+ /** A local parameter */
+ final val ParamAndLocal = allOf(Param, Local)
+
/** Labeled protected[this] */
final val ProtectedLocal = allOf(Protected, Local)
diff --git a/src/dotty/tools/dotc/core/Names.scala b/src/dotty/tools/dotc/core/Names.scala
index c7fedbc4c..e5535cff3 100644
--- a/src/dotty/tools/dotc/core/Names.scala
+++ b/src/dotty/tools/dotc/core/Names.scala
@@ -3,6 +3,8 @@ package core
import scala.io.Codec
import util.NameTransformer
+import printing.{Showable, Texts, Printer}
+import Texts.Text
import Decorators._
import Contexts.Context
import collection.IndexedSeqOptimized
@@ -17,7 +19,7 @@ object Names {
/** A common class for things that can be turned into names.
* Instances are both names and strings, the latter via a decorator.
*/
- trait PreName extends Any {
+ trait PreName extends Any with Showable {
def toTypeName: TypeName
def toTermName: TermName
}
@@ -90,7 +92,7 @@ object Names {
override def toString =
if (length == 0) "" else new String(chrs, start, length)
- def show(implicit ctx: Context): String = ctx.nameString(this)
+ def toText(printer: Printer): Text = printer.toText(this)
/** Write to UTF8 representation of this name to given character array.
* Start copying to index `to`. Return index of next free byte in array.
diff --git a/src/dotty/tools/dotc/core/Scopes.scala b/src/dotty/tools/dotc/core/Scopes.scala
index 426d5a51a..82ec0a30a 100644
--- a/src/dotty/tools/dotc/core/Scopes.scala
+++ b/src/dotty/tools/dotc/core/Scopes.scala
@@ -13,6 +13,7 @@ import Decorators._
import Contexts._
import Denotations._
import printing.Texts._
+import printing.Printer
import SymDenotations.NoDenotation
object Scopes {
@@ -108,7 +109,7 @@ object Scopes {
syms
}
- final def toText(implicit ctx: Context): Text = ctx.toText(this)
+ final def toText(printer: Printer): Text = printer.toText(this)
}
/** A subclass of Scope that defines methods for entering and
diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala
index 7d9fa9d44..b6efdcd36 100644
--- a/src/dotty/tools/dotc/core/Symbols.scala
+++ b/src/dotty/tools/dotc/core/Symbols.scala
@@ -11,6 +11,7 @@ import Decorators._
import Symbols._
import Contexts._
import SymDenotations._, printing.Texts._
+import printing.Printer
import Types._, Annotations._, util.Positions._, StdNames._, Trees._, NameOps._
import Denotations.{ Denotation, SingleDenotation, MultiDenotation }
import collection.mutable
@@ -382,7 +383,7 @@ object Symbols {
if (lastDenot == null) s"Naked$prefixString#$id"
else lastDenot.toString +"#"+id // !!! DEBUG
- def toText(implicit ctx: Context): Text = ctx.toText(this)
+ def toText(printer: Printer): Text = printer.toText(this)
def showLocated(implicit ctx: Context): String = ctx.locatedText(this).show
def showDcl(implicit ctx: Context): Text = ctx.dclText(this).show
diff --git a/src/dotty/tools/dotc/core/Trees.scala b/src/dotty/tools/dotc/core/Trees.scala
index f99e72196..9ac738929 100644
--- a/src/dotty/tools/dotc/core/Trees.scala
+++ b/src/dotty/tools/dotc/core/Trees.scala
@@ -8,6 +8,7 @@ import language.higherKinds
import collection.mutable
import collection.mutable.ArrayBuffer
import parsing.Tokens.Token
+import printing.Printer
import util.Stats
object Trees {
@@ -212,7 +213,7 @@ object Trees {
def orElse(that: => Tree[T]): Tree[T] =
if (this eq theEmptyTree) that else this
- override def toText(implicit ctx: Context) = ctx.toText(this)
+ override def toText(printer: Printer) = printer.toText(this)
override def hashCode(): Int = System.identityHashCode(this)
override def equals(that: Any) = this eq that.asInstanceOf[AnyRef]
@@ -429,7 +430,7 @@ object Trees {
}
/** try block catch handler finally finalizer */
- case class Try[T >: Untyped](block: Tree[T], handler: Tree[T], finalizer: Tree[T])
+ case class Try[T >: Untyped](expr: Tree[T], handler: Tree[T], finalizer: Tree[T])
extends TermTree[T] {
type ThisTree[T >: Untyped] = Try[T]
}
@@ -531,11 +532,6 @@ object Trees {
type ThisTree[T >: Untyped] = DefDef[T]
}
- class ImplicitDefDef[T >: Untyped](mods: Modifiers[T], name: TermName, tparams: List[TypeDef[T]], vparamss: List[List[ValDef[T]]], tpt: Tree[T], rhs: Tree[T]) extends DefDef[T](mods, name, tparams, vparamss, tpt, rhs) {
- override def copy[T >: Untyped](mods: Modifiers[T], name: TermName, tparams: List[TypeDef[T]], vparamss: List[List[ValDef[T]]], tpt: Tree[T], rhs: Tree[T]) =
- new ImplicitDefDef[T](mods, name, tparams, vparamss, tpt, rhs)
- }
-
/** mods type name = rhs or
* mods type name >: lo <: hi, if rhs = TypeBoundsTree(lo, hi)
*/
@@ -769,9 +765,9 @@ object Trees {
case tree: Return[_] if (expr eq tree.expr) && (from eq tree.from) => tree
case _ => Return(expr, from).copyAttr(tree)
}
- def derivedTry(block: Tree[T], handler: Tree[T], finalizer: Tree[T]): Try[T] = tree match {
- case tree: Try[_] if (block eq tree.block) && (handler eq tree.handler) && (finalizer eq tree.finalizer) => tree
- case _ => Try(block, handler, finalizer).copyAttr(tree)
+ def derivedTry(expr: Tree[T], handler: Tree[T], finalizer: Tree[T]): Try[T] = tree match {
+ case tree: Try[_] if (expr eq tree.expr) && (handler eq tree.handler) && (finalizer eq tree.finalizer) => tree
+ case _ => Try(expr, handler, finalizer).copyAttr(tree)
}
def derivedThrow(expr: Tree[T]): Throw[T] = tree match {
case tree: Throw[_] if (expr eq tree.expr) => tree
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 46b718968..ea3c9ca59 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -17,6 +17,7 @@ import Denotations._
import Periods._
import TypedTrees.tpd._, TypedTrees.TreeMapper, printing.Texts._
import transform.Erasure
+import printing.Printer
import scala.util.hashing.{ MurmurHash3 => hashing }
import collection.mutable
@@ -735,7 +736,7 @@ object Types {
*/
def signature(implicit ctx: Context): Signature = NotAMethod
- def toText(implicit ctx: Context): Text = ctx.toText(this, printing.Printers.GlobalPrec)
+ def toText(printer: Printer): Text = printer.toText(this)
// ----- hashing ------------------------------------------------------
diff --git a/src/dotty/tools/dotc/core/UntypedTrees.scala b/src/dotty/tools/dotc/core/UntypedTrees.scala
index 6fa830a45..80aeba77e 100644
--- a/src/dotty/tools/dotc/core/UntypedTrees.scala
+++ b/src/dotty/tools/dotc/core/UntypedTrees.scala
@@ -23,7 +23,7 @@ object UntypedTrees {
/** (vparams) => body */
case class SymbolLit(str: String) extends Tree
- case class InterpolatedString(id: TermName, stringParts: List[Tree], elems: List[Tree]) extends Tree
+ case class InterpolatedString(id: TermName, strings: List[Literal], elems: List[Tree]) extends Tree
case class Function(args: List[Tree], body: Tree) extends Tree
case class InfixOp(left: Tree, op: Name, right: Tree) extends Tree
case class PostfixOp(tree: Tree, op: Name) extends Tree
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index 1c9ce4b8a..5083ccf52 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -11,6 +11,7 @@ import Contexts._, Symbols._, Types._, Scopes._, SymDenotations._, Names._, Name
import StdNames._, Denotations._, NameOps._, Flags._, Constants._, Annotations._
import util.Positions._, TypedTrees.tpd._, TypedTrees.TreeOps
import printing.Texts._
+import printing.Printer
import io.AbstractFile
import scala.reflect.internal.pickling.PickleFormat._
import Decorators._
@@ -24,8 +25,8 @@ object UnPickler {
class BadSignature(msg: String) extends RuntimeException(msg)
case class TempPolyType(tparams: List[Symbol], tpe: Type) extends UncachedGroundType {
- override def toText(implicit ctx: Context): Text =
- "[" ~ ctx.dclsText(tparams, ", ") ~ "]" ~ tpe.show
+ override def fallbackToText(printer: Printer): Text =
+ "[" ~ printer.dclsText(tparams, ", ") ~ "]" ~ printer.toText(tpe)
}
/** Temporary type for classinfos, will be decomposed on completion of the class */