Skip to content

Commit bc869e7

Browse files
committed
Add CyclicImplicitVal error to messages (reverted from commit 559e493)
1 parent 559e493 commit bc869e7

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -899,15 +899,4 @@ object messages {
899899
val msg = hl"trying to define package with same name as `$existing`"
900900
val explanation = ""
901901
}
902-
903-
case class CyclicImplicitVal(cycleSym: Symbol)(implicit ctx: Context)
904-
extends Message(34) {
905-
val kind = "Cyclic Reference"
906-
val msg = em"cyclic reference involving $cycleSym"
907-
val explanation =
908-
hl"""|This happens when the right hand-side of $cycleSym's definition
909-
|involves an implicit search.
910-
|
911-
|To avoid the error, give $cycleSym an explicit type."""
912-
}
913902
}

compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object ErrorReporting {
2828

2929
def cyclicErrorMsg(ex: CyclicReference)(implicit ctx: Context) = {
3030
val cycleSym = ex.denot.symbol
31-
def errorMsg(msg: String, cx: Context): Message =
31+
def errorMsg(msg: String, cx: Context): String =
3232
if (cx.mode is Mode.InferringReturnType) {
3333
cx.tree match {
3434
case tree: untpd.ValOrDefDef =>
@@ -48,7 +48,9 @@ object ErrorReporting {
4848
} else msg
4949

5050
if (cycleSym.is(Implicit, butNot = Method) && cycleSym.owner.isTerm)
51-
CyclicImplicitVal(cycleSym)
51+
em"""cyclic reference involving implicit $cycleSym
52+
|This happens when the right hand-side of $cycleSym's definition involves an implicit search.
53+
|To avoid the error, give $cycleSym an explicit type."""
5254
else
5355
errorMsg(ex.show, ctx)
5456
}

0 commit comments

Comments
 (0)