@@ -5,7 +5,7 @@ package typer
55import ast ._
66import core ._
77import Types ._ , ProtoTypes ._ , Contexts ._ , Decorators ._ , Denotations ._ , Symbols ._
8- import Implicits ._ , Flags ._
8+ import Implicits ._ , Flags ._ , Constants . Constant
99import util .Spans ._
1010import util .SourcePosition
1111import java .util .regex .Matcher .quoteReplacement
@@ -98,7 +98,13 @@ object ErrorReporting {
9898 val normTp = normalize(tree.tpe, pt)
9999 val treeTp = if (normTp <:< pt) tree.tpe else normTp
100100 // use normalized type if that also shows an error, original type otherwise
101- errorTree(tree, TypeMismatch (treeTp, pt, implicitFailure.whyNoConversion))
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))
102108 }
103109
104110 /** A subtype log explaining why `found` does not conform to `expected` */
0 commit comments