Skip to content

Commit 4bef48f

Browse files
oderskyBlaisorblade
authored andcommitted
Fix^2 context in CyclicReference toMessage
1 parent e85e516 commit 4bef48f

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

compiler/src/dotty/tools/dotc/core/TypeErrors.scala

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,21 @@ object handleRecursive {
8888

8989
class CyclicReference private (val denot: SymDenotation) extends TypeError {
9090

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)
91+
override def toMessage(implicit ctx: Context) = {
92+
93+
def errorMsg(cx: Context): Message =
94+
if (cx.mode is Mode.InferringReturnType) {
95+
cx.tree match {
96+
case tree: untpd.DefDef if !tree.tpt.typeOpt.exists =>
97+
OverloadedOrRecursiveMethodNeedsResultType(tree.name)
98+
case tree: untpd.ValDef if !tree.tpt.typeOpt.exists =>
99+
RecursiveValueNeedsResultType(tree.name)
100+
case _ =>
101+
errorMsg(cx.outer)
102+
}
100103
}
101-
}
102-
else CyclicReferenceInvolving(denot)
104+
else CyclicReferenceInvolving(denot)
103105

104-
override def toMessage(implicit ctx: Context) = {
105106
val cycleSym = denot.symbol
106107
if (cycleSym.is(Implicit, butNot = Method) && cycleSym.owner.isTerm)
107108
CyclicReferenceInvolvingImplicit(cycleSym)

0 commit comments

Comments
 (0)