Skip to content

Commit

Permalink
backtick when path segment is scala keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
chikei committed Oct 29, 2024
1 parent 8263201 commit 0909e66
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions integration/feature/keyword-module/resources/build.mill
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package build
import $packages._
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package build.`import`
import mill._, scalalib._

object `package` extends RootModule with ScalaModule {
def scalaVersion = "2.13.11"
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package `import`

object foo
15 changes: 15 additions & 0 deletions integration/feature/keyword-module/src/KeywordModuleTests.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package mill.integration

import mill.testkit.UtestIntegrationTestSuite

import utest._

object KeywordModuleTest extends UtestIntegrationTestSuite {
val tests: Tests = Tests {
test("test") - integrationTest { tester =>
import tester._

assert(eval("import.compile").isSuccess)
}
}
}
3 changes: 2 additions & 1 deletion runner/src/mill/runner/FileImportGraph.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import mill.main.client.CodeGenConstants._
import mill.main.client.OutFiles._

import scala.reflect.NameTransformer.encode
import scala.reflect.runtime
import scala.collection.mutable

/**
Expand Down Expand Up @@ -33,7 +34,7 @@ case class FileImportGraph(
object FileImportGraph {
def backtickWrap(s: String): String = s match {
case s"`$v`" => s
case _ => if (encode(s) == s) s else "`" + s + "`"
case _ => if (encode(s) == s) runtime.universe.asInstanceOf[runtime.JavaUniverse].quotedName(s) else "`" + s + "`"
}

import mill.api.JsonFormatters.pathReadWrite
Expand Down

0 comments on commit 0909e66

Please sign in to comment.