aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-02-23 13:10:28 +0100
committerMartin Odersky <odersky@gmail.com>2017-02-23 13:10:28 +0100
commitc6a09827b2c871cf85bbd0b87c55acb8344d3b97 (patch)
treeac1b941eb647cfea4f57224d5320970187cd7e29 /compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala
parenta0f47a00131935d85f957a80d0c4472eaa7b5baa (diff)
downloaddotty-c6a09827b2c871cf85bbd0b87c55acb8344d3b97.tar.gz
dotty-c6a09827b2c871cf85bbd0b87c55acb8344d3b97.tar.bz2
dotty-c6a09827b2c871cf85bbd0b87c55acb8344d3b97.zip
Better error messages for missing type of recursive definitions
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala15
1 files changed, 4 insertions, 11 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala b/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala
index 9d6a01ab7..20946b530 100644
--- a/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala
+++ b/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala
@@ -31,17 +31,10 @@ object ErrorReporting {
def errorMsg(msg: String, cx: Context): String =
if (cx.mode is Mode.InferringReturnType) {
cx.tree match {
- case tree: untpd.ValOrDefDef =>
- // Dotty deviation: Was Trees.ValOrDefDef[_], but this gives ValOrDefDef[Nothing] instead of
- // ValOrDefDel[Null]. Scala handles it, but it looks accidental because bounds propagation
- // fails if the parameter is invariant or cotravariant.
- // See test pending/pos/boundspropagation.scala
- val treeSym = ctx.symOfContextTree(tree)
- if (treeSym.exists && treeSym.name == cycleSym.name && treeSym.owner == cycleSym.owner) {
- val result = if (cycleSym is Method) " result" else ""
- em"overloaded or recursive $cycleSym needs$result type"
- }
- else errorMsg(msg, cx.outer)
+ case tree: untpd.DefDef if !tree.tpt.typeOpt.exists =>
+ em"overloaded or recursive method ${tree.name} needs result type"
+ case tree: untpd.ValDef if !tree.tpt.typeOpt.exists =>
+ em"recursive value ${tree.name} needs type"
case _ =>
errorMsg(msg, cx.outer)
}