diff options
author | Enno Runne <enno@runne.net> | 2017-03-07 20:05:28 +0100 |
---|---|---|
committer | Enno Runne <enno@runne.net> | 2017-03-07 20:05:28 +0100 |
commit | 98465f930fe5d3f10401c454d6655da71243b923 (patch) | |
tree | 42888e27a553888a21628090e6aab562a96d8c83 /compiler/src/dotty/tools/dotc/reporting | |
parent | c3ec6dfbdeadb2fc9e7ac191b4c1a4d6838e8a5b (diff) | |
download | dotty-98465f930fe5d3f10401c454d6655da71243b923.tar.gz dotty-98465f930fe5d3f10401c454d6655da71243b923.tar.bz2 dotty-98465f930fe5d3f10401c454d6655da71243b923.zip |
Analysis of overloaded or recursive is harder than expected
Fall-back to reporting "overloaded or recursive needs type".
Diffstat (limited to 'compiler/src/dotty/tools/dotc/reporting')
-rw-r--r-- | compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java | 3 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala | 29 |
2 files changed, 13 insertions, 19 deletions
diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java b/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java index f6d0de352..a03e21d98 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java @@ -52,8 +52,7 @@ public enum ErrorMessageID { MixedLeftAndRightAssociativeOpsID, CantInstantiateAbstractClassOrTraitID, AnnotatedPrimaryConstructorRequiresModifierOrThisID, - OverloadedMethodNeedsResultTypeID, - RecursiveMethodNeedsResultTypeID, + OverloadedOrRecursiveMethodNeedsResultTypeID, RecursiveValueNeedsResultTypeID, CyclicReferenceInvolvingID, CyclicReferenceInvolvingImplicitID, diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 44ae98d82..a4db1b785 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -1162,23 +1162,18 @@ object messages { |""".stripMargin } - case class OverloadedMethodNeedsResultType(tree: Names.TermName)(implicit ctx: Context) - extends Message(OverloadedMethodNeedsResultTypeID) { + case class OverloadedOrRecursiveMethodNeedsResultType(tree: Names.TermName)(implicit ctx: Context) + extends Message(OverloadedOrRecursiveMethodNeedsResultTypeID) { val kind = "Syntax" - val msg = hl"""overloaded method ${tree} needs result type""" + val msg = hl"""overloaded or recursive method ${tree} needs return type""" val explanation = - hl"""|${tree} is overloaded and at least one definition of it calls another. - |You need to specify the calling method's return type. - """.stripMargin - } - - case class RecursiveMethodNeedsResultType(tree: Names.TermName)(implicit ctx: Context) - extends Message(RecursiveMethodNeedsResultTypeID) { - val kind = "Syntax" - val msg = hl"""recursive method ${tree} needs result type""" - val explanation = - hl"""|The definition of `${tree.name}` is recursive and you need to specify its type. - """.stripMargin + hl"""Case 1: ${tree} is overloaded + |If there are multiple methods named `${tree.name}` and at least one definition of + |it calls another, you need to specify the calling method's return type. + | + |Case 2: ${tree} is recursive + |If `${tree.name}` calls itself on any path, you need to specify its return type. + |""".stripMargin } case class RecursiveValueNeedsResultType(tree: Names.TermName)(implicit ctx: Context) @@ -1186,8 +1181,8 @@ object messages { val kind = "Syntax" val msg = hl"""recursive value ${tree.name} needs type""" val explanation = - hl"""|The definition of `${tree.name}` is recursive and you need to specify its type. - """.stripMargin + hl"""The definition of `${tree.name}` is recursive and you need to specify its type. + |""".stripMargin } case class CyclicReferenceInvolving(denot: SymDenotation)(implicit ctx: Context) |