Skip to content

Commit 63675c6

Browse files
authored
Merge pull request #36 from scala/backport-lts-3.3-19332
Backport "Flag class file collision as error" to 3.3 LTS
2 parents e04ea4a + 5b0d6df commit 63675c6

File tree

8 files changed

+20
-7
lines changed

8 files changed

+20
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class PostProcessor(val frontendAccess: PostProcessorFrontendAccess, val bTypes:
7373
else s" (defined in ${pos2.source.file.name})"
7474
def nicify(name: String): String = name.replace('/', '.').nn
7575
if name1 == name2 then
76-
backendReporting.warning(
76+
backendReporting.error(
7777
em"${nicify(name1)} and ${nicify(name2)} produce classes that overwrite one another", pos1)
7878
else
7979
backendReporting.warning(

tests/neg/i19248/Foo.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
trait Foo { // error
2+
class Bar
3+
4+
type T = Foo.this.Bar
5+
6+
inline def f: Int = ???
7+
}

tests/neg/i19248/Main.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@main
2+
def Main(args: String*): Unit =
3+
()

tests/neg/i19248/Scope.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object Scope {
2+
}
3+
object Foo {
4+
}

tests/neg/i19248/empty.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object foo {
2+
@main def foo(x: Int) = () // error: class foo and object foo produce classes that overwrite one another
3+
}

tests/pos-with-compiler-cc/backend/jvm/GenBCode.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class GenBCodePipeline(val int: DottyBackendInterface, val primitives: DottyPrim
213213
val same = classSymbol.effectiveName.toString == dupClassSym.effectiveName.toString
214214
atPhase(typerPhase) {
215215
if (same)
216-
report.warning( // FIXME: This should really be an error, but then FromTasty tests fail
216+
report.error(
217217
em"$cl1 and ${cl2.showLocated} produce classes that overwrite one another", cl1.sourcePos)
218218
else
219219
report.warning(

tests/warn/main-functions-nameclash.scala

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)