Skip to content

Commit 99b84e0

Browse files
committed
Encode path of class
1 parent 5429b1f commit 99b84e0

File tree

5 files changed

+28
-32
lines changed

5 files changed

+28
-32
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,9 +1310,9 @@ object Denotations {
13101310
}
13111311

13121312
/** The current denotation of the static reference given by path,
1313-
* or a MissingRef or NoQualifyingRef instance, if it does not exist.
1314-
* if generateStubs is set, generates stubs for missing top-level symbols
1315-
*/
1313+
* or a MissingRef or NoQualifyingRef instance, if it does not exist.
1314+
* if generateStubs is set, generates stubs for missing top-level symbols
1315+
*/
13161316
def staticRef(path: Name, generateStubs: Boolean = true, isPackage: Boolean = false)(using Context): Denotation = {
13171317
def select(prefix: Denotation, selector: Name): Denotation = {
13181318
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
@@ -505,15 +505,14 @@ object Phases {
505505
* Enrich crash messages.
506506
*/
507507
final def monitor(doing: String)(body: Context ?=> Unit)(using Context): Boolean =
508-
val unit = ctx.compilationUnit
509-
if ctx.run.enterUnit(unit) then
508+
ctx.run.enterUnit(ctx.compilationUnit)
509+
&& {
510510
try {body; true}
511511
catch case NonFatal(ex) if !ctx.run.enrichedErrorMessage =>
512-
report.echo(ctx.run.enrichErrorMessage(s"exception occurred while $doing $unit"))
512+
report.echo(ctx.run.enrichErrorMessage(s"exception occurred while $doing ${ctx.compilationUnit}"))
513513
throw ex
514514
finally ctx.run.advanceUnit()
515-
else
516-
false
515+
}
517516

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

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

Lines changed: 7 additions & 10 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, fromBestEffortTasty: Boolean = false): Option[String] =
2121
getClassName(file, fromBestEffortTasty).map { className =>
@@ -33,19 +33,16 @@ object TastyFileUtil {
3333
* ```
3434
* then `getClassName("./out/foo/Foo.tasty") returns `Some("foo.Foo")`
3535
*/
36-
def getClassName(file: AbstractFile, withBestEffortTasty: Boolean = false): Option[String] = {
36+
def getClassName(file: AbstractFile, withBestEffortTasty: Boolean = false): Option[String] =
3737
assert(file.exists)
3838
assert(file.hasTastyExtension || (withBestEffortTasty && file.hasBetastyExtension))
3939
val bytes = file.toByteArray
4040
val names = new TastyClassName(bytes, file.hasBetastyExtension).readName()
41-
names.map { case (packageName, className) =>
42-
val fullName = packageName match {
43-
case EMPTY_PACKAGE => s"${className.lastPart}"
44-
case _ => s"$packageName.${className.lastPart}"
45-
}
46-
fullName
47-
}
48-
}
41+
names.map: (packageName, className) =>
42+
if packageName == EMPTY_PACKAGE then
43+
s"${className.lastPart.encode}"
44+
else
45+
s"${packageName.encode}.${className.lastPart.encode}"
4946
}
5047

5148

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: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import scala.quoted.runtime.impl.QuotesImpl
1111
import dotty.tools.dotc.Compiler
1212
import dotty.tools.dotc.Driver
1313
import dotty.tools.dotc.Run
14-
import dotty.tools.dotc.core.Contexts.Context
14+
import dotty.tools.dotc.core.Contexts.{Context, ctx}
1515
import dotty.tools.dotc.core.Mode
1616
import dotty.tools.dotc.core.Phases.Phase
1717
import dotty.tools.dotc.fromtasty._
@@ -53,21 +53,19 @@ object ScaladocInternalTastyInspector:
5353
tastyFiles.foreach(checkFile(_, "tasty"))
5454
jars.foreach(checkFile(_, "jar"))
5555

56-
/**
57-
* Added for Scaladoc-only.
58-
* Meant to fix regressions introduces by the switch from old to new TastyInspector:
59-
* https://github.com/scala/scala3/issues/18231
60-
* https://github.com/scala/scala3/issues/20476
61-
* Stable TastyInspector API does not support passing compiler context.
62-
*/
56+
/** Added for Scaladoc-only.
57+
* Meant to fix regressions introduces by the switch from old to new TastyInspector:
58+
* - https://github.com/scala/scala3/issues/18231
59+
* - https://github.com/scala/scala3/issues/20476
60+
* Stable TastyInspector API does not support passing compiler context.
61+
*/
6362
def inspectAllTastyFilesInContext(tastyFiles: List[String], jars: List[String], dependenciesClasspath: List[String])(inspector: Inspector)(using Context): Boolean =
6463
checkFiles(tastyFiles, jars)
6564
val classes = tastyFiles ::: jars
66-
classes match
67-
case Nil => true
68-
case _ =>
69-
val reporter = inspectorDriver(inspector).process(inspectorArgs(dependenciesClasspath, classes), summon[Context])
70-
!reporter.hasErrors
65+
classes.isEmpty
66+
|| !inspectorDriver(inspector)
67+
.process(inspectorArgs(dependenciesClasspath, classes), ctx)
68+
.hasErrors
7169

7270
/** Load and process TASTy files using TASTy reflect
7371
*
@@ -90,7 +88,7 @@ object ScaladocInternalTastyInspector:
9088
override def phaseName: String = "tastyInspector"
9189

9290
override def runOn(units: List[CompilationUnit])(using ctx0: Context): List[CompilationUnit] =
93-
// NOTE: although this is a phase, do not expect this to be ran with an xsbti.CompileProgress
91+
// NOTE: although this is a phase, do not expect this to be run with an xsbti.CompileProgress
9492
val ctx = QuotesCache.init(ctx0.fresh)
9593
runOnImpl(units)(using ctx)
9694

0 commit comments

Comments
 (0)