aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/parsing/Parsers.scala4
-rw-r--r--src/dotty/tools/dotc/reporting/diagnostic/messages.scala34
-rw-r--r--src/dotty/tools/dotc/transform/TailRec.scala6
3 files changed, 39 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala
index 013541c71..6adb7f010 100644
--- a/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -1178,7 +1178,7 @@ object Parsers {
case _ =>
if (isLiteral) literal()
else {
- syntaxErrorOrIncomplete("illegal start of simple expression")
+ syntaxErrorOrIncomplete(IllegalStartSimpleExpr(tokenString(in.token)))
errorTermTree
}
}
@@ -1909,7 +1909,7 @@ object Parsers {
else EmptyTree
}
else {
- if (!isExprIntro) syntaxError("missing return type", in.lastOffset)
+ if (!isExprIntro) syntaxError(MissingReturnType(), in.lastOffset)
accept(EQUALS)
expr()
}
diff --git a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
index ce60d053a..c4e84aaee 100644
--- a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
+++ b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
@@ -275,10 +275,10 @@ object messages {
val explanation = ""
}
-
+
case class EarlyDefinitionsNotSupported()(implicit ctx:Context) extends Message(9) {
val kind = "Syntax"
-
+
val msg = "early definitions are not supported; use trait parameters instead"
val code1 =
@@ -482,4 +482,34 @@ object messages {
|but an uninitialized var definition
""".stripMargin
}
+
+ case class IllegalStartSimpleExpr(illegalToken: String)(implicit ctx: Context) extends Message(17) {
+ val kind = "Syntax"
+ val msg = "illegal start of simple expression"
+ val explanation = {
+ hl"""|An expression yields a value. In the case of the simple expression, this error
+ |commonly occurs when there's a missing parenthesis or brace. The reason being
+ |that a simple expression is one of the following:
+ |
+ |- Block
+ |- Expression in parenthesis
+ |- Identifier
+ |- Object creation
+ |- Literal
+ |
+ |which cannot start with ${Red(illegalToken)}.""".stripMargin
+ }
+ }
+
+ case class MissingReturnType()(implicit ctx:Context) extends Message(18) {
+ val kind = "Syntax"
+ val msg = "missing return type"
+ val explanation =
+ hl"""An abstract declaration must have a return type. For example:
+ |
+ |trait Shape {
+ | def area: Double // abstract declaration returning a ${"Double"}
+ |}""".stripMargin
+ }
+
}
diff --git a/src/dotty/tools/dotc/transform/TailRec.scala b/src/dotty/tools/dotc/transform/TailRec.scala
index d99a48af3..fde4db811 100644
--- a/src/dotty/tools/dotc/transform/TailRec.scala
+++ b/src/dotty/tools/dotc/transform/TailRec.scala
@@ -143,7 +143,11 @@ class TailRec extends MiniPhaseTransform with DenotTransformer with FullParamete
newOwners = label :: Nil
).transform(rhsSemiTransformed)
})
- Block(List(labelDef), ref(label).appliedToArgss(vparamss0.map(_.map(x=> ref(x.symbol)))))
+ val callIntoLabel = (
+ if (dd.tparams.isEmpty) ref(label)
+ else ref(label).appliedToTypes(dd.tparams.map(_.tpe))
+ ).appliedToArgss(vparamss0.map(_.map(x=> ref(x.symbol))))
+ Block(List(labelDef), callIntoLabel)
}} else {
if (mandatory) ctx.error(
"TailRec optimisation not applicable, method not tail recursive",