@@ -31,28 +31,21 @@ object ErrorReporting {
31
31
def errorMsg (msg : String , cx : Context ): String =
32
32
if (cx.mode is Mode .InferringReturnType ) {
33
33
cx.tree match {
34
- case tree : untpd.ValOrDefDef =>
35
- // Dotty deviation: Was Trees.ValOrDefDef[_], but this gives ValOrDefDef[Nothing] instead of
36
- // ValOrDefDel[Null]. Scala handles it, but it looks accidental because bounds propagation
37
- // fails if the parameter is invariant or cotravariant.
38
- // See test pending/pos/boundspropagation.scala
39
- val treeSym = ctx.symOfContextTree(tree)
40
- if (treeSym.exists && treeSym.name == cycleSym.name && treeSym.owner == cycleSym.owner) {
41
- val result = if (cycleSym is Method ) " result" else " "
42
- em " overloaded or recursive $cycleSym needs $result type "
43
- }
44
- else errorMsg(msg, cx.outer)
34
+ case tree : untpd.DefDef if ! tree.tpt.typeOpt.exists =>
35
+ em " overloaded or recursive method ${tree.name} needs result type "
36
+ case tree : untpd.ValDef if ! tree.tpt.typeOpt.exists =>
37
+ em " recursive value ${tree.name} needs type "
45
38
case _ =>
46
39
errorMsg(msg, cx.outer)
47
40
}
48
41
} else msg
49
42
50
- if (cycleSym.is(Implicit , butNot = Method ) && cycleSym.owner.isTerm)
51
- em """ cyclic reference involving implicit $cycleSym
43
+ if (cycleSym.is(Implicit , butNot = Method ) && cycleSym.owner.isTerm)
44
+ em """ cyclic reference involving implicit $cycleSym
52
45
|This happens when the right hand-side of $cycleSym's definition involves an implicit search.
53
46
|To avoid the error, give $cycleSym an explicit type. """
54
- else
55
- errorMsg(ex.show, ctx)
47
+ else
48
+ errorMsg(ex.show, ctx)
56
49
}
57
50
58
51
def wrongNumberOfTypeArgs (fntpe : Type , expectedArgs : List [TypeParamInfo ], actual : List [untpd.Tree ], pos : Position )(implicit ctx : Context ) =
0 commit comments