aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/config/Printers.scala6
-rw-r--r--src/dotty/tools/dotc/reporting/Reporter.scala7
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala4
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala9
-rw-r--r--tests/pos/typers.scala6
5 files changed, 23 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/config/Printers.scala b/src/dotty/tools/dotc/config/Printers.scala
index 3dab2a234..407e93714 100644
--- a/src/dotty/tools/dotc/config/Printers.scala
+++ b/src/dotty/tools/dotc/config/Printers.scala
@@ -11,8 +11,10 @@ object Printers {
}
val core: Printer = noPrinter
- val typr: Printer = noPrinter
- val constr: Printer = noPrinter
+ val typr: Printer = new Printer
+ val constr: Printer = new Printer
+ val overload: Printer = noPrinter
+ val implicits: Printer = noPrinter
val unapp: Printer = noPrinter
} \ No newline at end of file
diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala
index 2faf1a481..913290a00 100644
--- a/src/dotty/tools/dotc/reporting/Reporter.scala
+++ b/src/dotty/tools/dotc/reporting/Reporter.scala
@@ -135,6 +135,10 @@ trait Reporting { this: Context =>
if (cond) traceIndented(question, show)(op)
else op
+ def traceIndented[T](printer: config.Printers.Printer, question: => String, show: Boolean = false)(op: => T): T =
+ if (printer ne config.Printers.noPrinter) traceIndented(question, show)(op)
+ else op
+
def traceIndented[T](question: => String, show: Boolean = false)(op: => T): T = {
def resStr(res: Any): String = res match {
case res: printing.Showable if show => res.show
@@ -142,6 +146,7 @@ trait Reporting { this: Context =>
}
traceIndented[T](s"==> $question?", (res: Any) => s"<== $question = ${resStr(res)}")(op)
}
+
def traceIndented[T](leading: => String, trailing: Any => String)(op: => T): T = {
var finalized = false
var logctx = this
@@ -218,7 +223,7 @@ abstract class Reporter {
def hasErrors = count(ERROR.level) > 0
def hasWarnings = count(WARNING.level) > 0
-
+
def errorCounts: Any = count.clone
def wasSilent[T](counts: Any): Boolean = {
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 9ed05ff97..60216c41f 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -728,7 +728,7 @@ trait Applications extends Compatibility { self: Typer =>
/** In a set of overloaded applicable alternatives, is `alt1` at least as good as
* `alt2`? `alt1` and `alt2` are nonoverloaded references.
*/
- def isAsGood(alt1: TermRef, alt2: TermRef)(implicit ctx: Context): Boolean = track("isAsGood") { ctx.traceIndented(i"isAsGood($alt1, $alt2)") {
+ def isAsGood(alt1: TermRef, alt2: TermRef)(implicit ctx: Context): Boolean = track("isAsGood") { ctx.traceIndented(overload, i"isAsGood($alt1, $alt2)") {
assert(alt1 ne alt2)
@@ -747,7 +747,7 @@ trait Applications extends Compatibility { self: Typer =>
* 2. `tp2` and `tp1` are method or poly types and `tp2` can be applied to the parameters of `tp1`.
* 3. Neither `tp1` nor `tp2` are method or poly types and `tp1` is compatible with `tp2`.
*/
- def isAsSpecific(alt1: TermRef, tp1: Type, alt2: TermRef, tp2: Type): Boolean = ctx.traceIndented(i"isAsSpecific $tp1 $tp2") { tp1 match {
+ def isAsSpecific(alt1: TermRef, tp1: Type, alt2: TermRef, tp2: Type): Boolean = ctx.traceIndented(overload, i"isAsSpecific $tp1 $tp2") { tp1 match {
case tp1: PolyType =>
def bounds(tparamRefs: List[TypeRef]) = tp1.paramBounds map (_.substParams(tp1, tparamRefs))
val tparams = ctx.newTypeParams(alt1.symbol.owner, tp1.paramNames, EmptyFlags, bounds)
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala
index aaf0d2e76..4a85f6926 100644
--- a/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/src/dotty/tools/dotc/typer/Implicits.scala
@@ -24,6 +24,7 @@ import Inferencing._
import Applications._
import ErrorReporting._
import config.Config
+import config.Printers._
import collection.mutable
/** Implicit resolution */
@@ -64,7 +65,7 @@ object Implicits {
}
/** The implicit references that are eligible for expected type `tp` */
- lazy val eligible: List[TermRef] = ctx.traceIndented(i"eligible($tp), companions = ${companionRefs.toList}%, %", show = true)(filterMatching(tp))
+ lazy val eligible: List[TermRef] = ctx.traceIndented(implicits, i"eligible($tp), companions = ${companionRefs.toList}%, %", show = true)(filterMatching(tp))
override def toString =
i"OfTypeImplicits($tp), companions = ${companionRefs.toList}%, %; refs = $refs%, %."
@@ -208,7 +209,7 @@ trait ImplicitRunInfo { self: RunInfo =>
// todo: compute implicits directly, without going via companionRefs?
def computeImplicitScope(tp: Type): OfTypeImplicits = track("computeImplicicScope") {
- ctx.traceIndented(i"computeImplicitScope($tp)") {
+ ctx.traceIndented(implicits, i"computeImplicitScope($tp)") {
val comps = new TermRefSet
tp match {
case tp: NamedType =>
@@ -288,7 +289,7 @@ trait Implicits { self: Typer =>
* !!! todo: catch potential cycles
*/
def inferImplicit(pt: Type, argument: Tree, pos: Position)(implicit ctx: Context): SearchResult = track("inferImplicit") {
- ctx.traceIndented(s"search implicit ${pt.show}, arg = ${argument.show}: ${argument.tpe.show}, constraint = ${ctx.typerState.constraint.show}", show = true) {
+ ctx.traceIndented(implicits, s"search implicit ${pt.show}, arg = ${argument.show}: ${argument.tpe.show}, constraint = ${ctx.typerState.constraint.show}", show = true) {
assert(!pt.isInstanceOf[ExprType])
val isearch =
if (ctx.settings.explaintypes.value) new ExplainedImplicitSearch(pt, argument, pos)
@@ -341,7 +342,7 @@ trait Implicits { self: Typer =>
def searchImplicits(eligible: List[TermRef], contextual: Boolean): SearchResult = {
/** Try to typecheck an implicit reference */
- def typedImplicit(ref: TermRef)(implicit ctx: Context): SearchResult = track("typedImplicit") { ctx.traceIndented(i"typed implicit $ref, pt = $pt, implicitsEnabled == ${ctx.mode is ImplicitsEnabled}", show = true) {
+ def typedImplicit(ref: TermRef)(implicit ctx: Context): SearchResult = track("typedImplicit") { ctx.traceIndented(implicits, i"typed implicit $ref, pt = $pt, implicitsEnabled == ${ctx.mode is ImplicitsEnabled}", show = true) {
var generated: Tree = Ident(ref).withPos(pos)
if (!argument.isEmpty)
generated = typedUnadapted(
diff --git a/tests/pos/typers.scala b/tests/pos/typers.scala
index 1626731bd..edfd7b218 100644
--- a/tests/pos/typers.scala
+++ b/tests/pos/typers.scala
@@ -5,6 +5,12 @@ import collection.mutable._
object typers {
+ val names = List("a", "b", "c")
+ val ints = List(1, 2, 3)
+
+ for ((name, n) <- (names, ints).zipped)
+ println(name.length + n)
+
val entries = Array("abc", "def")
for ((x, i) <- entries.zipWithIndex)