diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index 4c7cd6fdc17..b3bba43619b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -852,9 +852,11 @@ trait TypeDiagnostics extends splain.SplainDiagnostics { else if (organics.length == 1) organics(0) else organics.find(_.pos.focus == pos.focus).getOrElse(organics(0)) } + def help = if (!badsym.isSynthetic || settings.cyclic.value) "" else + s"; $badsym is synthetic; use -Vcyclic to find which definition needs an explicit type" condOpt(tree) { - case ValDef(_, _, TypeTree(), _) => s"recursive $badsym needs type" - case DefDef(_, _, _, _, TypeTree(), _) => s"${cyclicAdjective(badsym)} $badsym needs result type" + case ValDef(_, _, TypeTree(), _) => s"recursive $badsym needs type$help" + case DefDef(_, _, _, _, TypeTree(), _) => s"${cyclicAdjective(badsym)} $badsym needs result type$help" case Import(_, _) => sm"""encountered unrecoverable cycle resolving import. |Note: this is often due in part to a class depending on a definition nested within its companion. diff --git a/test/files/neg/t7808b.check b/test/files/neg/t7808b.check index 5a3a7bbe395..1ece6555fe4 100644 --- a/test/files/neg/t7808b.check +++ b/test/files/neg/t7808b.check @@ -1,4 +1,4 @@ -t7808b.scala:5: error: recursive value x$1 needs type +t7808b.scala:5: error: recursive value x$1 needs type; value x$1 is synthetic; use -Vcyclic to find which definition needs an explicit type val (ls, rs) = z match { ^ 1 error