Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag class file collision as error #19332

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/backend/jvm/PostProcessor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PostProcessor(val frontendAccess: PostProcessorFrontendAccess, val bTypes:
else s" (defined in ${pos2.source.file.name})"
def nicify(name: String): String = name.replace('/', '.').nn
if name1 == name2 then
backendReporting.warning(
backendReporting.error(
em"${nicify(name1)} and ${nicify(name2)} produce classes that overwrite one another", pos1)
else
backendReporting.warning(
Expand Down
7 changes: 7 additions & 0 deletions tests/neg/i19248/Foo.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
trait Foo { // error
class Bar

type T = Foo.this.Bar

inline def f: Int = ???
}
3 changes: 3 additions & 0 deletions tests/neg/i19248/Main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@main
def Main(args: String*): Unit =
()
4 changes: 4 additions & 0 deletions tests/neg/i19248/Scope.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object Scope {
}
object Foo {
}
1 change: 1 addition & 0 deletions tests/neg/i19248/empty.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

3 changes: 3 additions & 0 deletions tests/neg/main-functions-nameclash.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object foo {
@main def foo(x: Int) = () // error: class foo and object foo produce classes that overwrite one another
}
2 changes: 1 addition & 1 deletion tests/pos-with-compiler-cc/backend/jvm/GenBCode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class GenBCodePipeline(val int: DottyBackendInterface, val primitives: DottyPrim
val same = classSymbol.effectiveName.toString == dupClassSym.effectiveName.toString
atPhase(typerPhase) {
if (same)
report.warning( // FIXME: This should really be an error, but then FromTasty tests fail
report.error(
em"$cl1 and ${cl2.showLocated} produce classes that overwrite one another", cl1.sourcePos)
else
report.warning(
Expand Down
5 changes: 0 additions & 5 deletions tests/warn/main-functions-nameclash.scala

This file was deleted.