aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-04-10 16:16:31 +0200
committerMartin Odersky <odersky@gmail.com>2017-04-10 16:16:31 +0200
commitb3d683a4088f3db894c026070449637ec74e92fd (patch)
treee7c57dda7013d64b25cdf9a6874db42bb836e18f
parent529346d241459f0d20e607fb5ea78b6091c8bc12 (diff)
downloaddotty-b3d683a4088f3db894c026070449637ec74e92fd.tar.gz
dotty-b3d683a4088f3db894c026070449637ec74e92fd.tar.bz2
dotty-b3d683a4088f3db894c026070449637ec74e92fd.zip
Explain skolem types
Strictly speaking, all the info about a skolem type is printed, e.g. A(?2) But it's reassuring to have an explanation line like ?2 is an unknown value of type A
-rw-r--r--compiler/src/dotty/tools/dotc/printing/Formatting.scala14
1 files changed, 11 insertions, 3 deletions
diff --git a/compiler/src/dotty/tools/dotc/printing/Formatting.scala b/compiler/src/dotty/tools/dotc/printing/Formatting.scala
index e8fa45403..aa25880c2 100644
--- a/compiler/src/dotty/tools/dotc/printing/Formatting.scala
+++ b/compiler/src/dotty/tools/dotc/printing/Formatting.scala
@@ -107,7 +107,7 @@ object Formatting {
else nonSensicalStartTag + str + nonSensicalEndTag
}
- private type Recorded = AnyRef /*Symbol | TypeParamRef*/
+ private type Recorded = AnyRef /*Symbol | TypeParamRef | SkolemType */
private class Seen extends mutable.HashMap[String, List[Recorded]] {
@@ -135,8 +135,13 @@ object Formatting {
if ((sym is ModuleClass) && sym.sourceModule.exists) simpleNameString(sym.sourceModule)
else seen.record(super.simpleNameString(sym), sym)
- override def TypeParamRefNameString(param: TypeParamRef): String =
- seen.record(super.TypeParamRefNameString(param), param)
+ override def ParamRefNameString(param: ParamRef): String =
+ seen.record(super.ParamRefNameString(param), param)
+
+ override def toTextRef(tp: SingletonType): Text = tp match {
+ case tp: SkolemType => seen.record(tp.repr, tp)
+ case _ => super.toTextRef(tp)
+ }
}
/** Create explanation for single `Recorded` type or symbol */
@@ -165,6 +170,8 @@ object Formatting {
s"is a type variable${addendum("constraint", ctx.typeComparer.bounds(param))}"
case sym: Symbol =>
s"is a ${ctx.printer.kindString(sym)}${sym.showExtendedLocation}${addendum("bounds", sym.info)}"
+ case tp: SkolemType =>
+ s"is an unknown value of type ${tp.widen.show}"
}
}
@@ -176,6 +183,7 @@ object Formatting {
private def explanations(seen: Seen)(implicit ctx: Context): String = {
def needsExplanation(entry: Recorded) = entry match {
case param: TypeParamRef => ctx.typerState.constraint.contains(param)
+ case skolem: SkolemType => true
case _ => false
}