Skip to content

Commit 1f4d527

Browse files
committed
Emit the warning with lexicographic ordering between the duplicates
1 parent a4b148e commit 1f4d527

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,13 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
195195
case None =>
196196
caseInsensitively.put(lowercaseJavaClassName, claszSymbol)
197197
case Some(dupClassSym) =>
198-
ctx.warning(s"Class ${claszSymbol.name} differs only in case from ${dupClassSym.name}. " +
199-
"Such classes will overwrite one another on case-insensitive filesystems.", cd.pos)
198+
// Order is not deterministic so we enforce lexicographic order between the duplicates for error-reporting
199+
if (claszSymbol.name.toString < dupClassSym.name.toString)
200+
ctx.warning(s"Class ${claszSymbol.name} differs only in case from ${dupClassSym.name}. " +
201+
"Such classes will overwrite one another on case-insensitive filesystems.", claszSymbol.pos)
202+
else
203+
ctx.warning(s"Class ${dupClassSym.name} differs only in case from ${claszSymbol.name}. " +
204+
"Such classes will overwrite one another on case-insensitive filesystems.", dupClassSym.pos)
200205
}
201206

202207
// -------------- mirror class, if needed --------------

tests/neg-custom-args/i2673.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
package Foos
22

3-
class Foo
4-
class foo // error
3+
class Foo // error
4+
class foo

0 commit comments

Comments
 (0)