File tree Expand file tree Collapse file tree 1 file changed +16
-14
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 1 file changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -86,25 +86,27 @@ object handleRecursive {
86
86
}
87
87
}
88
88
89
- class CyclicReference private (val denot : SymDenotation ) extends TypeError {
89
+ class CyclicReference private (val denot : SymDenotation )(implicit val ctx : Context ) extends TypeError {
90
+
91
+ def errorMsg (cx : Context ): Message =
92
+ if (cx.mode is Mode .InferringReturnType ) {
93
+ cx.tree match {
94
+ case tree : untpd.DefDef if ! tree.tpt.typeOpt.exists =>
95
+ OverloadedOrRecursiveMethodNeedsResultType (tree.name)
96
+ case tree : untpd.ValDef if ! tree.tpt.typeOpt.exists =>
97
+ RecursiveValueNeedsResultType (tree.name)
98
+ case _ =>
99
+ errorMsg(cx.outer)
100
+ }
101
+ }
102
+ else CyclicReferenceInvolving (denot)
103
+
90
104
override def toMessage (implicit ctx : Context ) = {
91
105
val cycleSym = denot.symbol
92
- def errorMsg (msg : Message , cx : Context ): Message =
93
- if (cx.mode is Mode .InferringReturnType ) {
94
- cx.tree match {
95
- case tree : untpd.DefDef if ! tree.tpt.typeOpt.exists =>
96
- OverloadedOrRecursiveMethodNeedsResultType (tree.name)
97
- case tree : untpd.ValDef if ! tree.tpt.typeOpt.exists =>
98
- RecursiveValueNeedsResultType (tree.name)
99
- case _ =>
100
- errorMsg(msg, cx.outer)
101
- }
102
- } else msg
103
-
104
106
if (cycleSym.is(Implicit , butNot = Method ) && cycleSym.owner.isTerm)
105
107
CyclicReferenceInvolvingImplicit (cycleSym)
106
108
else
107
- CyclicReferenceInvolving (denot )
109
+ errorMsg( this .ctx )
108
110
}
109
111
}
110
112
You can’t perform that action at this time.
0 commit comments