diff options
author | Enno Runne <enno@runne.net> | 2017-03-04 16:32:33 +0100 |
---|---|---|
committer | Enno Runne <enno@runne.net> | 2017-03-04 16:32:33 +0100 |
commit | 34e3508cccbbcc49554a4c5b13419769cc3c7bf9 (patch) | |
tree | ea3b36dfe22dbcafd476be88e3512023e5a8d8da /compiler/src/dotty/tools/dotc/reporting | |
parent | e1e13e92d276d76aa73aacc764f64166adbe306c (diff) | |
download | dotty-34e3508cccbbcc49554a4c5b13419769cc3c7bf9.tar.gz dotty-34e3508cccbbcc49554a4c5b13419769cc3c7bf9.tar.bz2 dotty-34e3508cccbbcc49554a4c5b13419769cc3c7bf9.zip |
Explanations for recursive/cyclic type requirements
Diffstat (limited to 'compiler/src/dotty/tools/dotc/reporting')
-rw-r--r-- | compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index f2f69b6cc..9d899923b 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -1146,46 +1146,48 @@ object messages { |""".stripMargin } + case class AnnotatedPrimaryConstructorRequiresModifierOrThis(cls: Name)(implicit ctx: Context) + extends Message(AnnotatedPrimaryConstructorRequiresModifierOrThisID) { + val kind = "Syntax" + val msg = hl"""${"private"}, ${"protected"}, or ${"this"} expected for annotated primary constructor""" + val explanation = + hl"""|When using annotations with a primary constructor of a class, + |the annotation must be followed by an access modifier + |(${"private"} or ${"protected"}) or ${"this"}. + | + |For example: + | ${"class Sample @deprecated this(param: Parameter) { ..."} + | ^^^^ + |""".stripMargin + } + case class OverloadedOrRecursiveMethodNeedsResultType(tree: Names.TermName)(implicit ctx: Context) extends Message(OverloadedOrRecursiveMethodNeedsResultTypeID) { val kind = "Syntax" val msg = hl"""overloaded or recursive method ${tree} needs result type""" val explanation = - hl""" - | - """.stripMargin + 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 RecursiveValueNeedsResultType(tree: Names.TermName)(implicit ctx: Context) - extends Message(RecursiveValueNeedsResultTypeID) { + extends Message(RecursiveValueNeedsResultTypeID) { val kind = "Syntax" val msg = hl"""recursive value ${tree.name} needs type""" val explanation = - hl"""""".stripMargin + hl"""|The definition of `${tree.name}` is recursive and you need to specify its type. + """.stripMargin } case class CyclicReferenceInvolvingImplicit(cycleSym: Symbol)(implicit ctx: Context) - extends Message(CyclicReferenceInvolvingImplicitID) { + extends Message(CyclicReferenceInvolvingImplicitID) { val kind = "Syntax" val msg = hl"""cyclic reference involving implicit $cycleSym""" val explanation = hl"""|This happens when the right hand-side of $cycleSym's definition involves an implicit search. - |To avoid the error, give $cycleSym an explicit type. + |To avoid this error, give `${cycleSym.name}` an explicit type. |""".stripMargin } - case class AnnotatedPrimaryConstructorRequiresModifierOrThis(cls: Name)(implicit ctx: Context) - extends Message(AnnotatedPrimaryConstructorRequiresModifierOrThisID) { - val kind = "Syntax" - val msg = hl"""${"private"}, ${"protected"}, or ${"this"} expected for annotated primary constructor""" - val explanation = - hl"""|When using annotations with a primary constructor of a class, - |the annotation must be followed by an access modifier - |(${"private"} or ${"protected"}) or ${"this"}. - | - |For example: - | ${"class Sample @deprecated this(param: Parameter) { ..."} - | ^^^^ - |""".stripMargin - } } |