aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/syntax-summary.txt2
-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
-rw-r--r--tests/pending/pos/polytypes.scala9
5 files changed, 18 insertions, 24 deletions
diff --git a/docs/syntax-summary.txt b/docs/syntax-summary.txt
index 519180775..0a52ec802 100644
--- a/docs/syntax-summary.txt
+++ b/docs/syntax-summary.txt
@@ -96,7 +96,7 @@ grammar.
ClassQualifier ::= `[' id `]'
Type ::= FunArgTypes `=>' Type Function(ts, t)
- | HkTypeParamClause `->' Type TypeLambda(ps, t)
+ | HkTypeParamClause `=>' Type TypeLambda(ps, t)
| InfixType
FunArgTypes ::= InfixType
| `(' [ FunArgType {`,' FunArgType } ] `)'
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
diff --git a/tests/pending/pos/polytypes.scala b/tests/pending/pos/polytypes.scala
new file mode 100644
index 000000000..ec6c89d10
--- /dev/null
+++ b/tests/pending/pos/polytypes.scala
@@ -0,0 +1,9 @@
+object Test {
+
+ type T = [+X] => (List[X] => List[X])
+
+ def reverse[X](xs: List[X]): List[X] = ???
+
+ // val x: T = reverse
+
+}