@@ -1855,61 +1855,53 @@ object SymDenotations {
1855
1855
* The elements of the returned pre-denotation all
1856
1856
* have existing symbols.
1857
1857
*/
1858
- final def membersNamed (name : Name )(using Context ): PreDenotation = {
1859
- val privates = info.decls.denotsNamed(name, selectPrivate)
1860
- privates union nonPrivateMembersNamed(name).filterDisjoint(privates)
1861
- }
1862
-
1863
- /** All non-private members of this class that have the given name.
1864
- * The elements of the returned pre-denotation all
1865
- * have existing symbols.
1866
- * @param inherited The method is called on a parent class from computeNPMembersNamed
1867
- */
1868
- final def nonPrivateMembersNamed (name : Name )(using Context ): PreDenotation = {
1869
- Stats .record(" nonPrivateMembersNamed" )
1870
- if (Config .cacheMembersNamed) {
1858
+ final def membersNamed (name : Name )(using Context ): PreDenotation =
1859
+ Stats .record(" membersNamed" )
1860
+ if Config .cacheMembersNamed then
1871
1861
var denots : PreDenotation = memberCache.lookup(name)
1872
- if ( denots == null ) {
1873
- denots = computeNPMembersNamed (name)
1862
+ if denots == null then
1863
+ denots = computeMembersNamed (name)
1874
1864
memberCache.enter(name, denots)
1875
- }
1876
- else if (Config .checkCacheMembersNamed) {
1877
- val denots1 = computeNPMembersNamed(name)
1865
+ else if Config .checkCacheMembersNamed then
1866
+ val denots1 = computeMembersNamed(name)
1878
1867
assert(denots.exists == denots1.exists, s " cache inconsistency: cached: $denots, computed $denots1, name = $name, owner = $this" )
1879
- }
1880
1868
denots
1881
- }
1882
- else computeNPMembersNamed(name)
1883
- }
1869
+ else computeMembersNamed(name)
1870
+
1884
1871
1885
- private [core] def computeNPMembersNamed (name : Name )(using Context ): PreDenotation = {
1886
- Stats .record(" computeNPMembersNamed after fingerprint" )
1887
- ensureCompleted()
1888
- val ownDenots = info.decls.denotsNamed(name, selectNonPrivate)
1889
- if (debugTrace) // DEBUG
1872
+ /** All non-private members of this class that have the given name.
1873
+ * The elements of the returned pre-denotation all have existing symbols.
1874
+ */
1875
+ final def nonPrivateMembersNamed (name : Name )(using Context ): PreDenotation =
1876
+ val mbr = membersNamed(name)
1877
+ val nonPrivate = mbr.filterWithFlags(EmptyFlags , Private )
1878
+ if nonPrivate eq mbr then mbr
1879
+ else addInherited(name, nonPrivate)
1880
+
1881
+ private [core] def computeMembersNamed (name : Name )(using Context ): PreDenotation =
1882
+ Stats .record(" computeMembersNamed" )
1883
+ val ownDenots = info.decls.denotsNamed(name)
1884
+ if debugTrace then
1890
1885
println(s " $this.member( $name), ownDenots = $ownDenots" )
1891
- def collect (denots : PreDenotation , parents : List [Type ]): PreDenotation = parents match {
1886
+ if name.isConstructorName then ownDenots
1887
+ else addInherited(name, ownDenots)
1888
+
1889
+ private def addInherited (name : Name , ownDenots : PreDenotation )(using Context ): PreDenotation =
1890
+ def collect (denots : PreDenotation , parents : List [Type ]): PreDenotation = parents match
1892
1891
case p :: ps =>
1893
1892
val denots1 = collect(denots, ps)
1894
- p.classSymbol.denot match {
1893
+ p.classSymbol.denot match
1895
1894
case parentd : ClassDenotation =>
1896
- denots1.union(
1897
- parentd.nonPrivateMembersNamed(name)
1898
- .mapInherited(ownDenots, denots1, thisType))
1895
+ val inherited = parentd.nonPrivateMembersNamed(name)
1896
+ denots1.union(inherited.mapInherited(ownDenots, denots1, thisType))
1899
1897
case _ =>
1900
1898
denots1
1901
- }
1902
- case nil =>
1903
- denots
1904
- }
1905
- if (name.isConstructorName) ownDenots
1906
- else collect(ownDenots, classParents)
1907
- }
1899
+ case nil => denots
1900
+ collect(ownDenots, classParents)
1908
1901
1909
- override final def findMember (name : Name , pre : Type , required : FlagSet , excluded : FlagSet )(using Context ): Denotation = {
1910
- val raw = if ( excluded.is(Private )) nonPrivateMembersNamed(name) else membersNamed(name)
1902
+ override final def findMember (name : Name , pre : Type , required : FlagSet , excluded : FlagSet )(using Context ): Denotation =
1903
+ val raw = if excluded.is(Private ) then nonPrivateMembersNamed(name) else membersNamed(name)
1911
1904
raw.filterWithFlags(required, excluded).asSeenFrom(pre).toDenot(pre)
1912
- }
1913
1905
1914
1906
/** Compute tp.baseType(this) */
1915
1907
final def baseTypeOf (tp : Type )(using Context ): Type = {
@@ -2213,8 +2205,9 @@ object SymDenotations {
2213
2205
* object that hides a class or object in the scala package of the same name, because
2214
2206
* the behavior would then be unintuitive for such members.
2215
2207
*/
2216
- override def computeNPMembersNamed (name : Name )(using Context ): PreDenotation = {
2217
- def recur (pobjs : List [ClassDenotation ], acc : PreDenotation ): PreDenotation = pobjs match {
2208
+ override def computeMembersNamed (name : Name )(using Context ): PreDenotation =
2209
+
2210
+ def recur (pobjs : List [ClassDenotation ], acc : PreDenotation ): PreDenotation = pobjs match
2218
2211
case pcls :: pobjs1 =>
2219
2212
if (pcls.isCompleting) recur(pobjs1, acc)
2220
2213
else
@@ -2225,12 +2218,11 @@ object SymDenotations {
2225
2218
}
2226
2219
recur(pobjs1, acc.union(pobjMembers))
2227
2220
case nil =>
2228
- val directMembers = super .computeNPMembersNamed (name)
2221
+ val directMembers = super .computeMembersNamed (name)
2229
2222
if ! acc.exists then directMembers
2230
2223
else acc.union(directMembers.filterWithPredicate(! _.symbol.isAbsent())) match
2231
2224
case d : DenotUnion => dropStale(d)
2232
2225
case d => d
2233
- }
2234
2226
2235
2227
def dropStale (multi : DenotUnion ): PreDenotation =
2236
2228
val compiledNow = multi.filterWithPredicate(d =>
@@ -2272,13 +2264,12 @@ object SymDenotations {
2272
2264
multi.filterWithPredicate(_.symbol.associatedFile == chosen)
2273
2265
end dropStale
2274
2266
2275
- if ( symbol `eq` defn.ScalaPackageClass ) {
2276
- val denots = super .computeNPMembersNamed (name)
2277
- if ( denots.exists || name == nme.CONSTRUCTOR ) denots
2267
+ if symbol eq defn.ScalaPackageClass then
2268
+ val denots = super .computeMembersNamed (name)
2269
+ if denots.exists || name == nme.CONSTRUCTOR then denots
2278
2270
else recur(packageObjs, NoDenotation )
2279
- }
2280
2271
else recur(packageObjs, NoDenotation )
2281
- }
2272
+ end computeMembersNamed
2282
2273
2283
2274
/** The union of the member names of the package and the package object */
2284
2275
override def memberNames (keepOnly : NameFilter )(implicit onBehalf : MemberNames , ctx : Context ): Set [Name ] = {
0 commit comments