Skip to content

Commit 36ee954

Browse files
authored
Make order of renames and missing imports deterministic (#19468)
Fixes #19467
2 parents 0b7a785 + 92a3f26 commit 36ee954

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

presentation-compiler/src/main/dotty/tools/pc/printer/ShortenedTypePrinter.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import org.eclipse.lsp4j.TextEdit
3636
* A type printer that shortens types by replacing fully qualified names with shortened versions.
3737
*
3838
* The printer supports symbol renames found in scope and will use the rename if it is available.
39-
* It also handlse custom renames as specified in the `renameConfigMap` parameter.
39+
* It also handle custom renames as specified in the `renameConfigMap` parameter.
4040
*/
4141
class ShortenedTypePrinter(
4242
symbolSearch: SymbolSearch,
@@ -45,7 +45,7 @@ class ShortenedTypePrinter(
4545
isTextEdit: Boolean = false,
4646
renameConfigMap: Map[Symbol, String] = Map.empty
4747
)(using indexedCtx: IndexedContext, reportCtx: ReportContext) extends RefinedPrinter(indexedCtx.ctx):
48-
private val missingImports: mutable.Set[ImportSel] = mutable.Set.empty
48+
private val missingImports: mutable.Set[ImportSel] = mutable.LinkedHashSet.empty
4949
private val defaultWidth = 1000
5050

5151
private val methodFlags =
@@ -62,9 +62,9 @@ class ShortenedTypePrinter(
6262
AbsOverride,
6363
Lazy
6464
)
65-
66-
private val foundRenames = collection.mutable.Map.empty[Symbol, String]
67-
65+
66+
private val foundRenames = collection.mutable.LinkedHashMap.empty[Symbol, String]
67+
6868
def getUsedRenamesInfo(using Context): List[String] =
6969
foundRenames.map { (from, to) =>
7070
s"type $to = ${from.showName}"
@@ -190,7 +190,7 @@ class ShortenedTypePrinter(
190190

191191
override protected def selectionString(tp: NamedType): String =
192192
indexedCtx.rename(tp.symbol) match
193-
case Some(value) =>
193+
case Some(value) =>
194194
foundRenames += tp.symbol -> value
195195
value
196196
case None => super.selectionString(tp)

0 commit comments

Comments
 (0)