From 737592f7062403c02b38a155a4f092b6744b7f7a Mon Sep 17 00:00:00 2001 From: IDoCodingStuffs Date: Thu, 7 Feb 2019 15:55:02 -0500 Subject: [PATCH 1/4] Initial changes with references to MaxClassFileLength and variants replaced with MaxNameLength and variants hardcoded to 240 --- compiler/src/dotty/tools/dotc/config/ScalaSettings.scala | 1 - compiler/src/dotty/tools/dotc/core/NameOps.scala | 3 ++- .../sbt-test/source-dependencies/compactify/build.sbt | 7 +------ tests/pending/run/t8199.scala | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 75e574c152c8..6fb2e758087d 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -64,7 +64,6 @@ class ScalaSettings extends Settings.SettingGroup { val Xhelp: Setting[Boolean] = BooleanSetting("-X", "Print a synopsis of advanced options.") val XnoForwarders: Setting[Boolean] = BooleanSetting("-Xno-forwarders", "Do not generate static forwarders in mirror classes.") val XmaxInlines: Setting[Int] = IntSetting("-Xmax-inlines", "Maximal number of successive inlines", 32) - val XmaxClassfileName: Setting[Int] = IntSetting("-Xmax-classfile-name", "Maximum filename length for generated classes", 255, 72 to 255) val Xmigration: Setting[ScalaVersion] = VersionSetting("-Xmigration", "Warn about constructs whose behavior may have changed since version.") val Xprint: Setting[List[String]] = PhasesSetting("-Xprint", "Print out program after") val XprintTypes: Setting[Boolean] = BooleanSetting("-Xprint-types", "Print tree types (debugging option).") diff --git a/compiler/src/dotty/tools/dotc/core/NameOps.scala b/compiler/src/dotty/tools/dotc/core/NameOps.scala index 7bb897c0d73b..5a7a0b09e4ca 100644 --- a/compiler/src/dotty/tools/dotc/core/NameOps.scala +++ b/compiler/src/dotty/tools/dotc/core/NameOps.scala @@ -27,7 +27,8 @@ object NameOps { */ def apply(s: String)(implicit ctx: Context): String = { val marker = "$$$$" - val limit: Int = ctx.settings.XmaxClassfileName.value + + val limit: Int = 240 val MaxNameLength = (limit - 6) min 2 * (limit - 6 - 2 * marker.length - 32) def toMD5(s: String, edge: Int): String = { diff --git a/sbt-dotty/sbt-test/source-dependencies/compactify/build.sbt b/sbt-dotty/sbt-test/source-dependencies/compactify/build.sbt index 121f59cd756b..6e12cef8669e 100644 --- a/sbt-dotty/sbt-test/source-dependencies/compactify/build.sbt +++ b/sbt-dotty/sbt-test/source-dependencies/compactify/build.sbt @@ -2,9 +2,4 @@ TaskKey[Unit]("output-empty") := { val outputDirectory = (classDirectory in Compile).value val classes = (outputDirectory ** "*.class").get if (classes.nonEmpty) sys.error("Classes existed:\n\t" + classes.mkString("\n\t")) else () -} - -// apparently Travis CI stopped allowing long file names -// it fails with the default setting of 255 characters so -// we have to set lower limit ourselves -scalacOptions ++= Seq("-Xmax-classfile-name", "240") +} \ No newline at end of file diff --git a/tests/pending/run/t8199.scala b/tests/pending/run/t8199.scala index d84f6fc72a54..c96be4287ea1 100644 --- a/tests/pending/run/t8199.scala +++ b/tests/pending/run/t8199.scala @@ -39,7 +39,7 @@ object Test extends dotty.runtime.LegacyApp { checkClassName(c.getName) } def checkClassName(name: String): Unit = { - val defaultMaxClassFileLength = 255 + val defaultMaxClassFileLength = 240 assert((name + ".class").length <= defaultMaxClassFileLength, name) } def checkCallerImplClassName(): Unit = { From 72a191faf96b637f4bc7fe64df58b670c1df9eca Mon Sep 17 00:00:00 2001 From: "Paolo G. Giarrusso" Date: Sat, 9 Feb 2019 04:16:47 +0100 Subject: [PATCH 2/4] Fixup --- sbt-dotty/sbt-test/source-dependencies/compactify/build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbt-dotty/sbt-test/source-dependencies/compactify/build.sbt b/sbt-dotty/sbt-test/source-dependencies/compactify/build.sbt index 6e12cef8669e..e57676a05b38 100644 --- a/sbt-dotty/sbt-test/source-dependencies/compactify/build.sbt +++ b/sbt-dotty/sbt-test/source-dependencies/compactify/build.sbt @@ -2,4 +2,4 @@ TaskKey[Unit]("output-empty") := { val outputDirectory = (classDirectory in Compile).value val classes = (outputDirectory ** "*.class").get if (classes.nonEmpty) sys.error("Classes existed:\n\t" + classes.mkString("\n\t")) else () -} \ No newline at end of file +} From 79321bd6b7e4cda8ce8cadd74e4af5df81e5e37a Mon Sep 17 00:00:00 2001 From: IDoCodingStuffs Date: Sat, 9 Feb 2019 09:48:55 -0500 Subject: [PATCH 3/4] Removed unused context, renamed constant --- compiler/src/dotty/tools/dotc/core/NameOps.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/NameOps.scala b/compiler/src/dotty/tools/dotc/core/NameOps.scala index 5a7a0b09e4ca..1b67459e0c13 100644 --- a/compiler/src/dotty/tools/dotc/core/NameOps.scala +++ b/compiler/src/dotty/tools/dotc/core/NameOps.scala @@ -25,11 +25,11 @@ object NameOps { * * (+6 for ".class"). MaxNameLength can therefore be computed as follows: */ - def apply(s: String)(implicit ctx: Context): String = { + def apply(s: String): String = { val marker = "$$$$" - val limit: Int = 240 - val MaxNameLength = (limit - 6) min 2 * (limit - 6 - 2 * marker.length - 32) + final val charLimit: Int = 240 + val MaxNameLength = (charLimit - 6) min 2 * (charLimit - 6 - 2 * marker.length - 32) def toMD5(s: String, edge: Int): String = { val prefix = s take edge From ab68976fa7b3b5af58c08caf22c02042ab945cf9 Mon Sep 17 00:00:00 2001 From: IDoCodingStuffs Date: Sat, 9 Feb 2019 11:02:58 -0500 Subject: [PATCH 4/4] Carried character limit to final val --- compiler/src/dotty/tools/dotc/core/NameOps.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/NameOps.scala b/compiler/src/dotty/tools/dotc/core/NameOps.scala index 419e45944501..7f26a68687fe 100644 --- a/compiler/src/dotty/tools/dotc/core/NameOps.scala +++ b/compiler/src/dotty/tools/dotc/core/NameOps.scala @@ -13,6 +13,8 @@ object NameOps { object compactify { lazy val md5: MessageDigest = MessageDigest.getInstance("MD5") + final val CLASSFILE_NAME_CHAR_LIMIT = 240 + /** COMPACTIFY * * The hashed name has the form (prefix + marker + md5 + marker + suffix), where @@ -28,8 +30,8 @@ object NameOps { def apply(s: String): String = { val marker = "$$$$" - val charLimit: Int = 240 - val MaxNameLength = (charLimit - 6) min 2 * (charLimit - 6 - 2 * marker.length - 32) + val MaxNameLength = (CLASSFILE_NAME_CHAR_LIMIT - 6) min + 2 * (CLASSFILE_NAME_CHAR_LIMIT - 6 - 2 * marker.length - 32) def toMD5(s: String, edge: Int): String = { val prefix = s take edge