Skip to content

Commit

Permalink
Don't treat package object's <init> methods as package members (#16667)
Browse files Browse the repository at this point in the history
Extends [`b848c57`
(#7862)](b848c57)
to all packages.

Previously when asking for `dotty.tools.dotc.util.<init>` we'd get a
TypeError because both
`LinearMap$package`'s and `LinearSet$package`'s constructors have the
same modification time (in the jar).
  • Loading branch information
odersky authored Jan 13, 2023
2 parents be10bc6 + 63ff0c6 commit a90338d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2515,9 +2515,12 @@ object SymDenotations {
multi.filterWithPredicate(_.symbol.associatedFile == chosen)
end dropStale

if symbol eq defn.ScalaPackageClass then
if name == nme.CONSTRUCTOR then
NoDenotation // packages don't have constructors, even if package objects do.
else if symbol eq defn.ScalaPackageClass then
// revert order: search package first, then nested package objects
val denots = super.computeMembersNamed(name)
if denots.exists || name == nme.CONSTRUCTOR then denots
if denots.exists then denots
else recur(packageObjs, NoDenotation)
else recur(packageObjs, NoDenotation)
end computeMembersNamed
Expand Down

0 comments on commit a90338d

Please sign in to comment.