Skip to content

Commit

Permalink
Only count associated files of direct members of package objects in d…
Browse files Browse the repository at this point in the history
…ropStale (#22190)

possible fix for #17394
  • Loading branch information
KacperFKorban authored Dec 16, 2024
1 parent 2dbb27c commit da176c3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2539,7 +2539,9 @@ object SymDenotations {
)
if compiledNow.exists then compiledNow
else
val assocFiles = multi.aggregate(d => Set(d.symbol.associatedFile.nn), _ union _)
val assocFiles = multi
.filterWithPredicate(_.symbol.maybeOwner.isPackageObject)
.aggregate(d => Set(d.symbol.associatedFile.nn), _ union _)
if assocFiles.size == 1 then
multi // they are all overloaded variants from the same file
else
Expand Down
9 changes: 9 additions & 0 deletions tests/pos/i17394/_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package example:
def xd: Int = ???

package bar:
trait A:
def foo: String = ???

package object example extends bar.A:
def foo(x: String): String = ???
4 changes: 4 additions & 0 deletions tests/pos/i17394/_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import example.*

@main def main =
val _ = foo
9 changes: 9 additions & 0 deletions tests/pos/i17394b/_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package example:
def xd: Int = ???

package bar:
trait A:
def foo: String = ???

package object example extends bar.A:
def foo(x: String): String = ???
5 changes: 5 additions & 0 deletions tests/pos/i17394b/_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//> using options -Wunused:imports

import example.{given, *}

@main def main = ()

0 comments on commit da176c3

Please sign in to comment.