diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala | 9 | ||||
-rw-r--r-- | test/files/neg/case-collision.check | 10 | ||||
-rw-r--r-- | test/files/neg/case-collision.flags | 1 | ||||
-rw-r--r-- | test/files/neg/case-collision.scala | 11 |
4 files changed, 30 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index 6eb05c4402..61f3721da1 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -160,7 +160,14 @@ abstract class GenASM extends SubComponent with BytecodeWriters { } // For predictably ordered error messages. - var sortedClasses = classes.values.toList sortBy ("" + _.symbol.fullName) + var sortedClasses = classes.values.toList sortBy (_.symbol.fullName) + + // Warn when classes will overwrite one another on case-insensitive systems. + for ((_, v1 :: v2 :: _) <- sortedClasses groupBy (_.symbol.javaClassName.toString.toLowerCase)) { + v1.cunit.warning(v1.symbol.pos, + s"Class ${v1.symbol.javaClassName} differs only in case from ${v2.symbol.javaClassName}. " + + "Such classes will overwrite one another on case-insensitive filesystems.") + } debuglog("Created new bytecode generator for " + classes.size + " classes.") val bytecodeWriter = initBytecodeWriter(sortedClasses filter isJavaEntryPoint) diff --git a/test/files/neg/case-collision.check b/test/files/neg/case-collision.check new file mode 100644 index 0000000000..4edc6f1205 --- /dev/null +++ b/test/files/neg/case-collision.check @@ -0,0 +1,10 @@ +case-collision.scala:5: error: Class foo.BIPPY differs only in case from foo.Bippy. Such classes will overwrite one another on case-insensitive filesystems. +class BIPPY + ^ +case-collision.scala:11: error: Class foo.HyRaX$ differs only in case from foo.Hyrax$. Such classes will overwrite one another on case-insensitive filesystems. +object HyRaX + ^ +case-collision.scala:8: error: Class foo.DINGO$ differs only in case from foo.Dingo$. Such classes will overwrite one another on case-insensitive filesystems. +object DINGO + ^ +three errors found diff --git a/test/files/neg/case-collision.flags b/test/files/neg/case-collision.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/case-collision.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/case-collision.scala b/test/files/neg/case-collision.scala new file mode 100644 index 0000000000..241169a77a --- /dev/null +++ b/test/files/neg/case-collision.scala @@ -0,0 +1,11 @@ +package foo + +class Bippy + +class BIPPY + +object Dingo +object DINGO + +case class Hyrax() +object HyRaX |