Skip to content

Commit 53a6098

Browse files
committed
Sort suggestions alphabetically
This is needed to get stability of test outputs. But we should try to find more useful sorting criteria.
1 parent 9a3c33a commit 53a6098

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,9 @@ trait Implicits { self: Typer =>
761761
def suggestStr(ref: TermRef) = i" import ${refToString(ref)}"
762762
if suggestedRefs.isEmpty then ""
763763
else
764-
val suggestions = suggestedRefs.map(suggestStr).distinct
765-
// TermRefs might be different but generate the same strings
764+
val suggestions = suggestedRefs.map(suggestStr)
765+
.distinct // TermRefs might be different but generate the same strings
766+
.sorted // To get test stability. TODO: Find more useful sorting criteria
766767
val fix =
767768
if suggestions.tail.isEmpty then "The following import"
768769
else "One of the following imports"

compiler/test-resources/repl/importFromObj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ val res0: scala.collection.mutable.ListBuffer[Int] = ListBuffer(1, 2, 3)
1414
scala> import util.foo
1515
1 | import util.foo
1616
| ^^^
17-
| value foo is not a member of util - did you mean util.Try?
17+
| value foo is not a member of util
1818
scala> import util.foo.bar
1919
1 | import util.foo.bar
2020
| ^^^^^^^^
21-
| value foo is not a member of util - did you mean util.Try?
21+
| value foo is not a member of util

tests/neg/missing-implicit.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
|
66
| One of the following imports might fix the problem:
77
|
8-
| import math.Ordering.Implicits.infixOrderingOps
98
| import math.Ordered.orderingToOrdered
9+
| import math.Ordering.Implicits.infixOrderingOps
1010
|
1111
-- [E008] Member Not Found Error: tests/neg/missing-implicit.scala:5:51 ------------------------------------------------
1212
5 | case x :: xs1 if limit > 0 => consume(xs1, limit - x) // error // error
@@ -16,8 +16,8 @@
1616
| One of the following imports might fix the problem:
1717
|
1818
| import math.Fractional.Implicits.infixFractionalOps
19-
| import math.Numeric.Implicits.infixNumericOps
2019
| import math.Integral.Implicits.infixIntegralOps
20+
| import math.Numeric.Implicits.infixNumericOps
2121
|
2222
-- Error: tests/neg/missing-implicit.scala:10:24 -----------------------------------------------------------------------
2323
10 |val f = Future[Unit] { } // error

0 commit comments

Comments
 (0)