@@ -5,7 +5,7 @@ package typer
5
5
import ast ._
6
6
import core ._
7
7
import Types ._ , ProtoTypes ._ , Contexts ._ , Decorators ._ , Denotations ._ , Symbols ._
8
- import Implicits ._ , Flags ._
8
+ import Implicits ._ , Flags ._ , Constants . Constant
9
9
import util .Spans ._
10
10
import util .SourcePosition
11
11
import java .util .regex .Matcher .quoteReplacement
@@ -97,8 +97,14 @@ object ErrorReporting {
97
97
def typeMismatch (tree : Tree , pt : Type , implicitFailure : SearchFailureType = NoMatchingImplicits ): Tree = {
98
98
val normTp = normalize(tree.tpe, pt)
99
99
val treeTp = if (normTp <:< pt) tree.tpe else normTp
100
- // use normalized type if that also shows an error, original type otherwise
101
- errorTree(tree, TypeMismatch (treeTp, pt, implicitFailure.whyNoConversion))
100
+ // use normalized type if that also shows an error, original type otherwise
101
+ def missingElse = tree match
102
+ case If (_, _, elsep @ Literal (Constant (()))) if elsep.span.isSynthetic =>
103
+ " \n Maybe you are missing an else part for the conditional?"
104
+ case _ => " "
105
+ val addendum = List (implicitFailure.whyNoConversion, missingElse)
106
+ .find(! _.isEmpty).getOrElse(" " )
107
+ errorTree(tree, TypeMismatch (treeTp, pt, addendum))
102
108
}
103
109
104
110
/** A subtype log explaining why `found` does not conform to `expected` */
0 commit comments