diff --git a/compiler/src/dotty/tools/backend/jvm/GenBCode.scala b/compiler/src/dotty/tools/backend/jvm/GenBCode.scala index 27010b4d179a..c57929e4d363 100644 --- a/compiler/src/dotty/tools/backend/jvm/GenBCode.scala +++ b/compiler/src/dotty/tools/backend/jvm/GenBCode.scala @@ -24,6 +24,8 @@ import Contexts._ import Types._ import Symbols._ import Denotations._ +import Decorators._ + import Phases._ import java.lang.AssertionError import java.io.{DataOutputStream, File => JFile} @@ -188,18 +190,19 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter val claszSymbol = cd.symbol // GenASM checks this before classfiles are emitted, https://github.com/scala/scala/commit/e4d1d930693ac75d8eb64c2c3c69f2fc22bec739 - // todo: add back those checks - /*val lowercaseJavaClassName = claszSymbol.javaClassName.toLowerCase + val lowercaseJavaClassName = claszSymbol.name.toString.toLowerCase caseInsensitively.get(lowercaseJavaClassName) match { case None => caseInsensitively.put(lowercaseJavaClassName, claszSymbol) case Some(dupClassSym) => - reporter.warning( - claszSymbol.pos, - s"Class ${claszSymbol.javaClassName} differs only in case from ${dupClassSym.javaClassName}. " + - "Such classes will overwrite one another on case-insensitive filesystems." - ) - }*/ + // Order is not deterministic so we enforce lexicographic order between the duplicates for error-reporting + if (claszSymbol.name.toString < dupClassSym.name.toString) + ctx.warning(s"Class ${claszSymbol.name} differs only in case from ${dupClassSym.name}. " + + "Such classes will overwrite one another on case-insensitive filesystems.", claszSymbol.pos) + else + ctx.warning(s"Class ${dupClassSym.name} differs only in case from ${claszSymbol.name}. " + + "Such classes will overwrite one another on case-insensitive filesystems.", dupClassSym.pos) + } // -------------- mirror class, if needed -------------- val mirrorC = diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 53b6d775675f..386ada1329f5 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -194,7 +194,8 @@ class CompilationTests extends ParallelTesting { compileFile("../tests/neg-custom-args/i3882.scala", allowDeepSubtypes) + compileFile("../tests/neg-custom-args/phantom-overload.scala", allowDoubleBindings) + compileFile("../tests/neg-custom-args/phantom-overload-2.scala", allowDoubleBindings) + - compileFile("../tests/neg-custom-args/structural.scala", defaultOptions.and("-Xfatal-warnings")) + compileFile("../tests/neg-custom-args/structural.scala", defaultOptions.and("-Xfatal-warnings")) + + compileFile("../tests/neg-custom-args/i2673.scala", defaultOptions.and("-Xfatal-warnings")) }.checkExpectedErrors() // Run tests ----------------------------------------------------------------- diff --git a/tests/neg-custom-args/i2673.scala b/tests/neg-custom-args/i2673.scala new file mode 100644 index 000000000000..2cb4fb03874e --- /dev/null +++ b/tests/neg-custom-args/i2673.scala @@ -0,0 +1,4 @@ +package Foos + +class Foo // error +class foo