Skip to content

Fix #2681: re-enable check for potentially overridden classfiles #3897

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

Merged
merged 5 commits into from
Jan 27, 2018
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
19 changes: 11 additions & 8 deletions compiler/src/dotty/tools/backend/jvm/GenBCode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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 =
Expand Down
3 changes: 2 additions & 1 deletion compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 -----------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions tests/neg-custom-args/i2673.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package Foos

class Foo // error
class foo