Skip to content

Commit a90338d

Browse files
authored
Don't treat package object's <init> methods as package members (scala#16667)
Extends [`b848c57` (scala#7862)](scala@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).
2 parents be10bc6 + 63ff0c6 commit a90338d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -2515,9 +2515,12 @@ object SymDenotations {
25152515
multi.filterWithPredicate(_.symbol.associatedFile == chosen)
25162516
end dropStale
25172517

2518-
if symbol eq defn.ScalaPackageClass then
2518+
if name == nme.CONSTRUCTOR then
2519+
NoDenotation // packages don't have constructors, even if package objects do.
2520+
else if symbol eq defn.ScalaPackageClass then
2521+
// revert order: search package first, then nested package objects
25192522
val denots = super.computeMembersNamed(name)
2520-
if denots.exists || name == nme.CONSTRUCTOR then denots
2523+
if denots.exists then denots
25212524
else recur(packageObjs, NoDenotation)
25222525
else recur(packageObjs, NoDenotation)
25232526
end computeMembersNamed

0 commit comments

Comments
 (0)