Skip to content

Commit 1ff1862

Browse files
authored
Merge pull request #533 from scala/backport-lts-3.3-23503
Backport "Encode path of class" to 3.3 LTS
2 parents 5091e59 + bb6e368 commit 1ff1862

File tree

5 files changed

+17
-19
lines changed

5 files changed

+17
-19
lines changed

compiler/src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,9 +1299,9 @@ object Denotations {
12991299
}
13001300

13011301
/** The current denotation of the static reference given by path,
1302-
* or a MissingRef or NoQualifyingRef instance, if it does not exist.
1303-
* if generateStubs is set, generates stubs for missing top-level symbols
1304-
*/
1302+
* or a MissingRef or NoQualifyingRef instance, if it does not exist.
1303+
* if generateStubs is set, generates stubs for missing top-level symbols
1304+
*/
13051305
def staticRef(path: Name, generateStubs: Boolean = true, isPackage: Boolean = false)(using Context): Denotation = {
13061306
def select(prefix: Denotation, selector: Name): Denotation = {
13071307
val owner = prefix.disambiguate(_.info.isParameterless)

compiler/src/dotty/tools/dotc/core/Phases.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,15 +462,14 @@ object Phases {
462462
* Enrich crash messages.
463463
*/
464464
final def monitor(doing: String)(body: Context ?=> Unit)(using Context): Boolean =
465-
val unit = ctx.compilationUnit
466-
if ctx.run.enterUnit(unit) then
465+
ctx.run.enterUnit(ctx.compilationUnit)
466+
&& {
467467
try {body; true}
468468
catch case NonFatal(ex) if !ctx.run.enrichedErrorMessage =>
469-
report.echo(ctx.run.enrichErrorMessage(s"exception occurred while $doing $unit"))
469+
report.echo(ctx.run.enrichErrorMessage(s"exception occurred while $doing ${ctx.compilationUnit}"))
470470
throw ex
471471
finally ctx.run.advanceUnit()
472-
else
473-
false
472+
}
474473

475474
inline def runSubPhase[T](id: Run.SubPhase)(inline body: (Run.SubPhase, Context) ?=> T)(using Context): T =
476475
given Run.SubPhase = id

compiler/src/dotty/tools/dotc/fromtasty/TastyFileUtil.scala

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ object TastyFileUtil {
1515
* package foo
1616
* class Foo
1717
* ```
18-
* then `getClassName("./out/foo/Foo.tasty") returns `Some("./out")`
18+
* then `getClassPath("./out/foo/Foo.tasty") returns `Some("./out")`
1919
*/
2020
def getClassPath(file: AbstractFile): Option[String] =
2121
getClassName(file).map { className =>
@@ -37,14 +37,11 @@ object TastyFileUtil {
3737
assert(file.extension == "tasty")
3838
val bytes = file.toByteArray
3939
val names = new TastyClassName(bytes).readName()
40-
names.map { case (packageName, className) =>
41-
val fullName = packageName match {
42-
case EMPTY_PACKAGE => s"${className.lastPart}"
43-
case _ => s"$packageName.${className.lastPart}"
44-
}
45-
fullName
46-
}
47-
}
40+
names.map: (packageName, className) =>
41+
if packageName == EMPTY_PACKAGE then
42+
s"${className.lastPart.encode}"
43+
else
44+
s"${packageName.encode}.${className.lastPart.encode}"
4845
}
4946

5047

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
def exampleMember = "hello, world"

scaladoc/src/scala/tasty/inspector/TastyInspector.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import scala.quoted.runtime.impl.QuotesImpl
99
import dotty.tools.dotc.Compiler
1010
import dotty.tools.dotc.Driver
1111
import dotty.tools.dotc.Run
12-
import dotty.tools.dotc.core.Contexts.Context
12+
import dotty.tools.dotc.core.Contexts.{Context, ctx}
1313
import dotty.tools.dotc.core.Mode
1414
import dotty.tools.dotc.core.Phases.Phase
1515
import dotty.tools.dotc.fromtasty._
@@ -69,7 +69,7 @@ object TastyInspector:
6969
override def phaseName: String = "tastyInspector"
7070

7171
override def runOn(units: List[CompilationUnit])(using ctx0: Context): List[CompilationUnit] =
72-
// NOTE: although this is a phase, do not expect this to be ran with an xsbti.CompileProgress
72+
// NOTE: although this is a phase, do not expect this to be run with an xsbti.CompileProgress
7373
val ctx = QuotesCache.init(ctx0.fresh)
7474
runOnImpl(units)(using ctx)
7575

0 commit comments

Comments
 (0)