File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -899,4 +899,15 @@ object messages {
899
899
val msg = hl " trying to define package with same name as ` $existing` "
900
900
val explanation = " "
901
901
}
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
+ }
902
913
}
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ object ErrorReporting {
28
28
29
29
def cyclicErrorMsg (ex : CyclicReference )(implicit ctx : Context ) = {
30
30
val cycleSym = ex.denot.symbol
31
- def errorMsg (msg : String , cx : Context ): String =
31
+ def errorMsg (msg : String , cx : Context ): Message =
32
32
if (cx.mode is Mode .InferringReturnType ) {
33
33
cx.tree match {
34
34
case tree : untpd.ValOrDefDef =>
@@ -48,9 +48,7 @@ object ErrorReporting {
48
48
} else msg
49
49
50
50
if (cycleSym.is(Implicit , butNot = Method ) && cycleSym.owner.isTerm)
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. """
51
+ CyclicImplicitVal (cycleSym)
54
52
else
55
53
errorMsg(ex.show, ctx)
56
54
}
You can’t perform that action at this time.
0 commit comments