Skip to content

Commit 05215ab

Browse files
committed
Use URI to normalize path
1 parent f4a2736 commit 05215ab

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ object TastyImpl extends scala.tasty.Tasty {
4242
def ContextDeco(ctx: Context): AbstractContext = new AbstractContext {
4343
def owner: Definition = FromSymbol.definition(ctx.owner)(ctx)
4444

45-
def source: String = {
45+
def source: java.net.URI = {
4646
val thisPath = java.nio.file.Paths.get("").toAbsolutePath
4747
val path = ctx.compilationUnit.source.file.jpath.toAbsolutePath
48-
thisPath.relativize(path).toString
48+
thisPath.toUri.relativize(path.toUri)
4949
}
5050
}
5151

library/src/scala/tasty/Tasty.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class Tasty { tasty =>
3333
def owner: Definition
3434

3535
/** Returns the source file being compiled. The path is relative to the current working directory. */
36-
def source: String
36+
def source: java.net.URI
3737
}
3838
implicit def ContextDeco(ctx: Context): AbstractContext
3939

tests/run/tasty-getfile/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object SourceFiles {
99

1010
private def getThisFileImpl(implicit u: Universe): Expr[String] = {
1111
import u.tasty._
12-
u.context.source.toExpr
12+
u.context.source.toString.toExpr
1313
}
1414

1515
}

0 commit comments

Comments
 (0)