diff --git a/compiler/src/dotty/tools/backend/jvm/PostProcessor.scala b/compiler/src/dotty/tools/backend/jvm/PostProcessor.scala index 06c3c7f1cb4f..9f172806a3b5 100644 --- a/compiler/src/dotty/tools/backend/jvm/PostProcessor.scala +++ b/compiler/src/dotty/tools/backend/jvm/PostProcessor.scala @@ -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( diff --git a/tests/neg/i19248/Foo.scala b/tests/neg/i19248/Foo.scala new file mode 100644 index 000000000000..f24651234eb9 --- /dev/null +++ b/tests/neg/i19248/Foo.scala @@ -0,0 +1,7 @@ +trait Foo { // error + class Bar + + type T = Foo.this.Bar + + inline def f: Int = ??? +} diff --git a/tests/neg/i19248/Main.scala b/tests/neg/i19248/Main.scala new file mode 100644 index 000000000000..bf4e3a48b279 --- /dev/null +++ b/tests/neg/i19248/Main.scala @@ -0,0 +1,3 @@ +@main +def Main(args: String*): Unit = + () diff --git a/tests/neg/i19248/Scope.scala b/tests/neg/i19248/Scope.scala new file mode 100644 index 000000000000..a3135d93084f --- /dev/null +++ b/tests/neg/i19248/Scope.scala @@ -0,0 +1,4 @@ +object Scope { +} +object Foo { +} diff --git a/tests/neg/i19248/empty.scala b/tests/neg/i19248/empty.scala new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/tests/neg/i19248/empty.scala @@ -0,0 +1 @@ + diff --git a/tests/neg/main-functions-nameclash.scala b/tests/neg/main-functions-nameclash.scala new file mode 100644 index 000000000000..23a530e28271 --- /dev/null +++ b/tests/neg/main-functions-nameclash.scala @@ -0,0 +1,3 @@ +object foo { + @main def foo(x: Int) = () // error: class foo and object foo produce classes that overwrite one another +} diff --git a/tests/pos-with-compiler-cc/backend/jvm/GenBCode.scala b/tests/pos-with-compiler-cc/backend/jvm/GenBCode.scala index 1af7e5dd705a..3bc9fb5592ee 100644 --- a/tests/pos-with-compiler-cc/backend/jvm/GenBCode.scala +++ b/tests/pos-with-compiler-cc/backend/jvm/GenBCode.scala @@ -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( diff --git a/tests/warn/main-functions-nameclash.scala b/tests/warn/main-functions-nameclash.scala deleted file mode 100644 index bc0fe64379d4..000000000000 --- a/tests/warn/main-functions-nameclash.scala +++ /dev/null @@ -1,5 +0,0 @@ - - -object foo { - @main def foo(x: Int) = () // warn: class foo and object foo produce classes that overwrite one another -}