Skip to content

Commit 654cf03

Browse files
VLanvinfacebook-github-bot
authored andcommitted
Tweak error message heuristic for LHS unions
Summary: Tweak the heuristic as follows, for LHS unions: - If no candidate is above 40 of score (40 corresponds to the limit of a matching top-level constructor) then produce an `Incompatible` error without further explanation, as before; - Otherwise, if no candidate matches, then just display an explanation for the one with the lowest score; - Otherwise, as before: display a partial match. Reviewed By: ilya-klyuchnikov Differential Revision: D74998988 fbshipit-source-id: 6f3a71237471f96030e77b0f0f3218dd8d9b3ffb
1 parent 0ef8e04 commit 654cf03

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

eqwalizer/src/main/scala/com/whatsapp/eqwalizer/tc/TypeMismatch.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,10 @@ class TypeMismatch(pipelineContext: PipelineContext) {
262262
val tys1 = util.flattenUnions(ut)
263263
val details = tys1.map(findMismatch(_, t2, seen))
264264
val lowest = details.minBy(_.score)
265-
if (details.forall(_.mismatch.nonEmpty))
265+
if (details.forall(_.score < 40))
266266
Details(Some(subtype.join(tys1), t2, Incompatible), lowest.score)
267+
else if (details.forall(_.mismatch.nonEmpty))
268+
lowest
267269
else {
268270
lowest.mismatch match {
269271
case None => lowest

0 commit comments

Comments
 (0)