Skip to content

Commit a40bcfc

Browse files
committed
Improve clash error message
1 parent 566b395 commit a40bcfc

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,14 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
162162
val (cl1, cl2) =
163163
if (classSymbol.effectiveName.toString < dupClassSym.effectiveName.toString) (classSymbol, dupClassSym)
164164
else (dupClassSym, classSymbol)
165+
val same = classSymbol.effectiveName.toString == dupClassSym.effectiveName.toString
165166
ctx.atPhase(ctx.typerPhase) {
166-
the[Context].warning(s"${cl1.show} differs only in case from ${cl2.showLocated}. " +
167-
"Such classes will overwrite one another on case-insensitive filesystems.", cl1.sourcePos)
167+
if (same)
168+
the[Context].warning( // FIXME: This should really be an error, but then FromTasty tests fail
169+
s"${cl1.show} and ${cl2.showLocated} produce classes that overwrite one another", cl1.sourcePos)
170+
else
171+
the[Context].warning(s"${cl1.show} differs only in case from ${cl2.showLocated}. " +
172+
"Such classes will overwrite one another on case-insensitive filesystems.", cl1.sourcePos)
168173
}
169174
}
170175
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
object foo {
3-
@main def foo(x: Int) = () // error: class foo differs only in case from object foo
3+
@main def foo(x: Int) = () // error: class foo and object foo produce classes that overwrite one another
44
}

0 commit comments

Comments
 (0)