Skip to content

Commit 02d7594

Browse files
committed
Remove dead code and data in "did you mean" hints
1 parent c601a72 commit 02d7594

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ object messages {
343343
}
344344

345345
// Get closest match in `site`
346-
def closest =
346+
def closest: List[String] =
347347
decls
348348
.map { (n, sym) => (n, distance(n, name.show), sym) }
349349
.collect {
@@ -356,21 +356,19 @@ object messages {
356356
.headOption.map(_._2).getOrElse(Nil)
357357
.map(incorrectChars).toList
358358
.sortBy(_._3)
359-
.take(1).map { case (n, sym, _) => (n, sym) }
359+
.map(_._1)
360+
// [Martin] Note: I have no idea what this does. This shows the
361+
// pitfalls of not naming things, functional or not.
360362

361363
val finalAddendum =
362364
if addendum.nonEmpty then addendum
363365
else closest match {
364-
case (n, _) :: Nil =>
366+
case n :: _ =>
365367
val siteName = site match
366368
case site: NamedType => site.name.show
367369
case site => i"$site"
368370
s" - did you mean $siteName.$n?"
369371
case Nil => ""
370-
case _ => assert(
371-
false,
372-
"Could not single out one distinct member to match on input with"
373-
)
374372
}
375373

376374
ex"$selected $name is not a member of ${site.widen}$finalAddendum"

0 commit comments

Comments
 (0)