File tree 2 files changed +16
-1
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -2031,7 +2031,15 @@ object SymDenotations {
2031
2031
def recur (pobjs : List [ClassDenotation ], acc : PreDenotation ): PreDenotation = pobjs match {
2032
2032
case pcls :: pobjs1 =>
2033
2033
if (pcls.isCompleting) recur(pobjs1, acc)
2034
- else recur(pobjs1, acc.union(pcls.computeNPMembersNamed(name)))
2034
+ else {
2035
+ // A package object inherits members from `Any` and `Object` which
2036
+ // should not be accessible from the package prefix.
2037
+ val pmembers = pcls.computeNPMembersNamed(name).filterWithPredicate { d =>
2038
+ val owner = d.symbol.maybeOwner
2039
+ (owner ne defn.AnyClass ) && (owner ne defn.ObjectClass )
2040
+ }
2041
+ recur(pobjs1, acc.union(pmembers))
2042
+ }
2035
2043
case nil =>
2036
2044
val directMembers = super .computeNPMembersNamed(name)
2037
2045
if (acc.exists) acc.union(directMembers.filterWithPredicate(! _.symbol.isAbsent))
Original file line number Diff line number Diff line change
1
+ package object foo {
2
+ val x = 1
3
+ }
4
+ object Test {
5
+ foo.eq(??? ) // error
6
+ foo.== (??? ) // error
7
+ }
You can’t perform that action at this time.
0 commit comments