aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-10-10 09:40:08 +0200
committerGuillaume Martres <smarter@ubuntu.com>2016-10-12 16:13:49 +0200
commitd8127d2f0f31913cca7eb60a721b25974b3bfde6 (patch)
tree1cc9d26f86767589430afdd105cefa5eab21433a /src/dotty/tools/dotc
parentdf2187e51e7a38a6ca8260ab4a415a7cd5efdcfc (diff)
downloaddotty-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')
-rw-r--r--src/dotty/tools/dotc/parsing/Parsers.scala4
-rw-r--r--src/dotty/tools/dotc/printing/PlainPrinter.scala26
-rw-r--r--src/dotty/tools/dotc/printing/RefinedPrinter.scala1
3 files changed, 8 insertions, 23 deletions
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala
index ab4e38638..507a2e80c 100644
--- a/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -701,9 +701,9 @@ object Parsers {
else if (in.token == LBRACKET) {
val start = in.offset
val tparams = typeParamClause(ParamOwner.TypeParam)
- if (isIdent && in.name.toString == "->")
+ if (in.token == ARROW)
atPos(start, in.skipToken())(PolyTypeTree(tparams, typ()))
- else { syntaxErrorOrIncomplete(expectedMessage("`->'")); typ() }
+ else { accept(ARROW); typ() }
}
else infixType()
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) =>
diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
index bcd12bc86..6315cfabc 100644
--- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala
+++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
@@ -20,7 +20,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
/** A stack of enclosing DefDef, TypeDef, or ClassDef, or ModuleDefs nodes */
private var enclosingDef: untpd.Tree = untpd.EmptyTree
- private var lambdaNestingLevel: Int = 0
private var myCtx: Context = _ctx
override protected[this] implicit def ctx: Context = myCtx