diff options
author | Martin Odersky <odersky@gmail.com> | 2016-10-10 09:40:08 +0200 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2016-10-12 16:13:49 +0200 |
commit | d8127d2f0f31913cca7eb60a721b25974b3bfde6 (patch) | |
tree | 1cc9d26f86767589430afdd105cefa5eab21433a /src/dotty/tools/dotc/printing/PlainPrinter.scala | |
parent | df2187e51e7a38a6ca8260ab4a415a7cd5efdcfc (diff) | |
download | dotty-d8127d2f0f31913cca7eb60a721b25974b3bfde6.tar.gz dotty-d8127d2f0f31913cca7eb60a721b25974b3bfde6.tar.bz2 dotty-d8127d2f0f31913cca7eb60a721b25974b3bfde6.zip |
Use => instead of -> for PolyTypes
If PolyTypes are to become value types we want to keep `=>` as the arrow
for consistency. `->` should be reserved for PolyTypes that do not have
side effects on instantiation.
Diffstat (limited to 'src/dotty/tools/dotc/printing/PlainPrinter.scala')
-rw-r--r-- | src/dotty/tools/dotc/printing/PlainPrinter.scala | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/dotty/tools/dotc/printing/PlainPrinter.scala b/src/dotty/tools/dotc/printing/PlainPrinter.scala index 564ef21ef..785f57897 100644 --- a/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -114,25 +114,6 @@ class PlainPrinter(_ctx: Context) extends Printer { case _ => toTextGlobal(arg) } - /** The text for a PolyType - * - * [v_1 p_1: B_1, ..., v_n p_n: B_n] -> T - * - * where - * @param paramNames = p_1, ..., p_n - * @param variances = v_1, ..., v_n - * @param argBoundss = B_1, ..., B_n - * @param body = T - */ - protected def polyTypeText(paramNames: List[String], variances: List[Int], argBoundss: List[TypeBounds], body: Type): Text = { - def lambdaParamText(variance: Int, name: String, bounds: TypeBounds): Text = - varianceString(variance) ~ name ~ toText(bounds) - changePrec(GlobalPrec) { - "[" ~ Text((variances, paramNames, argBoundss).zipped.map(lambdaParamText), ", ") ~ - "] -> " ~ toTextGlobal(body) - } - } - /** The longest sequence of refinement types, starting at given type * and following parents. */ @@ -186,7 +167,12 @@ class PlainPrinter(_ctx: Context) extends Printer { case tp: ExprType => changePrec(GlobalPrec) { "=> " ~ toText(tp.resultType) } case tp: PolyType => - polyTypeText(tp.paramNames.map(_.toString), tp.variances, tp.paramBounds, tp.resultType) + def paramText(variance: Int, name: Name, bounds: TypeBounds): Text = + varianceString(variance) ~ name.toString ~ toText(bounds) + changePrec(GlobalPrec) { + "[" ~ Text((tp.variances, tp.paramNames, tp.paramBounds).zipped.map(paramText), ", ") ~ + "] => " ~ toTextGlobal(tp.resultType) + } case tp: PolyParam => polyParamNameString(tp) ~ polyHash(tp.binder) case AnnotatedType(tpe, annot) => |