@@ -241,7 +241,7 @@ object messages {
241
241
}
242
242
}
243
243
244
- class TypeMismatch (found : Type , expected : Type , addendum : => String = " " )(implicit ctx : Context )
244
+ class TypeMismatch (found : Type , expected : Type , addenda : => String * = Nil )(implicit ctx : Context )
245
245
extends TypeMismatchMsg (TypeMismatchID ):
246
246
247
247
// replace constrained TypeParamRefs and their typevars by their bounds where possible
@@ -269,14 +269,15 @@ object messages {
269
269
val expected1 = reported(expected)
270
270
val (found2, expected2) =
271
271
if (found1 frozen_<:< expected1) (found, expected) else (found1, expected1)
272
- val postScript =
273
- if ! addendum.isEmpty
274
- || expected.isAny
275
- || expected.isAnyRef
276
- || expected.isRef(defn.AnyValClass )
277
- || defn.isBottomType(found)
278
- then addendum
279
- else ctx.typer.importSuggestionAddendum(ViewProto (found.widen, expected))
272
+ val postscript = addenda.find(! _.isEmpty) match
273
+ case Some (p) => p
274
+ case None =>
275
+ if expected.isAny
276
+ || expected.isAnyRef
277
+ || expected.isRef(defn.AnyValClass )
278
+ || defn.isBottomType(found)
279
+ then " "
280
+ else ctx.typer.importSuggestionAddendum(ViewProto (found.widen, expected))
280
281
val (where, printCtx) = Formatting .disambiguateTypes(found2, expected2)
281
282
val whereSuffix = if (where.isEmpty) where else s " \n\n $where"
282
283
val (foundStr, expectedStr) = Formatting .typeDiff(found2, expected2)(printCtx)
0 commit comments