-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
Compiler version
sbt:scala3-nonbootstrapped> print scalaVersion
tasty-core-nonbootstrapped / scalaVersion
3.8.0-RC3
scala3-sbt-bridge-nonbootstrapped / scalaVersion
3.8.0-RC3
scala3-interfaces / scalaVersion
3.8.0-RC3
scala-library-nonbootstrapped / scalaVersion
3.8.0-RC3
scala3-compiler-nonbootstrapped / scalaVersion
3.8.0-RC3
scala3-library-nonbootstrapped / scalaVersion
3.8.0-RC3
scalaVersion
2.12.20Minimized code
N/A
Output
N/A
Expectation
In scala/scala#11192, I noticed that java.nio.file.Path.toURI() prepends the current working directory to Windows-like paths unconditionally, and converts backslashes in such paths to %5C escape sequences. @lrytz asked whether this happened with Scala3.
I added the following code to case SourcePattern in MessageFilter.matches() from compiler/src/dotty/tools/dotc/reporting/WConf.scala:
println("original: " + source.jfile.toString + "\nresolved: " + path)I added the following test case to compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala:
private def diagnosticWarning(source: util.SourceFile) = reporting.Diagnostic.Warning(
"A warning".toMessage,
util.SourcePosition(source = source, span = util.Spans.Span(1L))
)
@Test def `Wconf src filter handles Windows paths`: Unit =
val path = Path("C:\\foo\\bar\\myfile.scala")
val result = wconfSrcFilterTest(
argsStr = "-Wconf:src=foo/bar/.*\\.scala:s",
warning = diagnosticWarning(util.SourceFile(new PlainFile(path), "UTF-8"))
)
assertEquals(result, Right(reporting.Action.Silent))Then running testOnly dotty.tools.dotc.config.ScalaSettingsTests produced the following output before the test failure:
original: Optional[C:\foo\bar\myfile.scala]
resolved: /Users/mbland/src/scala/scala3/C:%5Cfoo%5Cbar%5Cmyfile.scalaI'll send a pull request based on scala/scala#11192 that contains the fix and a couple of new test cases.
lrytz