Skip to content

Commit 917d4d6

Browse files
authored
Merge pull request #419 from sjrd/fix-weird-toplevel-scala2-names
Fix #413: Handle inner classes based on content, not names.
2 parents 598e037 + 648de54 commit 917d4d6

File tree

6 files changed

+275
-251
lines changed

6 files changed

+275
-251
lines changed

tasty-query/shared/src/main/scala/tastyquery/Symbols.scala

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,6 @@ object Symbols {
18031803
private[Symbols] val specialKind: SpecialKind = computeSpecialKind(name, owner)
18041804

18051805
// DeclaringSymbol-related fields
1806-
private var rootsInitialized: Boolean = false
18071806
private val myDeclarations = mutable.HashMap[UnsignedName, Symbol]()
18081807
private val pendingDeclarations = mutable.HashMap[UnsignedName, Symbol]()
18091808
private var isLoadingNewRoots: Boolean = false
@@ -1833,6 +1832,9 @@ object Symbols {
18331832
/** Is this the root package? */
18341833
final def isRootPackage: Boolean = owner == null
18351834

1835+
/** Is this the empty package? */
1836+
private[tastyquery] def isEmptyPackage: Boolean = specialKind == SpecialKind.empty
1837+
18361838
/** Is this the scala package? */
18371839
private[tastyquery] def isScalaPackage: Boolean = specialKind == SpecialKind.scala
18381840

@@ -1891,10 +1893,6 @@ object Symbols {
18911893

18921894
isLoadingNewRoots = true
18931895
try
1894-
if !rootsInitialized then
1895-
ctx.classloader.scanPackage(this)
1896-
rootsInitialized = true
1897-
18981896
val result = op(ctx.classloader)
18991897

19001898
// Upon success, commit pending declations
@@ -1966,9 +1964,10 @@ object Symbols {
19661964
private[Symbols] object SpecialKind:
19671965
inline val None = 0
19681966
inline val root = 1
1969-
inline val scala = 2
1970-
inline val java = 3
1971-
inline val javaLang = 4
1967+
inline val empty = 2
1968+
inline val scala = 3
1969+
inline val java = 4
1970+
inline val javaLang = 5
19721971
end SpecialKind
19731972

19741973
private def computeSpecialKind(name: SimpleName, owner: PackageSymbol | Null): SpecialKind =
@@ -1977,6 +1976,7 @@ object Symbols {
19771976
(owner.specialKind: @switch) match
19781977
case SpecialKind.root =>
19791978
name match
1979+
case nme.EmptyPackageName => SpecialKind.empty
19801980
case nme.scalaPackageName => SpecialKind.scala
19811981
case nme.javaPackageName => SpecialKind.java
19821982
case _ => SpecialKind.None
@@ -1992,7 +1992,6 @@ object Symbols {
19921992

19931993
private[tastyquery] def createRoots(): (PackageSymbol, PackageSymbol) =
19941994
val root = PackageSymbol(nme.RootName, null)
1995-
root.rootsInitialized = true
19961995
val empty = PackageSymbol(nme.EmptyPackageName, root)
19971996
root.addDecl(empty)
19981997
(root, empty)

0 commit comments

Comments
 (0)