Skip to content

Commit e3fe46d

Browse files
KacperFKorbantgodzik
authored andcommitted
Only count associated files of direct members of package objects in dropStale (scala#22190)
possible fix for scala#17394 [Cherry-picked da176c3]
1 parent a0052dd commit e3fe46d

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -2523,7 +2523,9 @@ object SymDenotations {
25232523
)
25242524
if compiledNow.exists then compiledNow
25252525
else
2526-
val assocFiles = multi.aggregate(d => Set(d.symbol.associatedFile.nn), _ union _)
2526+
val assocFiles = multi
2527+
.filterWithPredicate(_.symbol.maybeOwner.isPackageObject)
2528+
.aggregate(d => Set(d.symbol.associatedFile.nn), _ union _)
25272529
if assocFiles.size == 1 then
25282530
multi // they are all overloaded variants from the same file
25292531
else

tests/pos/i17394/_1.scala

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package example:
2+
def xd: Int = ???
3+
4+
package bar:
5+
trait A:
6+
def foo: String = ???
7+
8+
package object example extends bar.A:
9+
def foo(x: String): String = ???

tests/pos/i17394/_2.scala

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import example.*
2+
3+
@main def main =
4+
val _ = foo

tests/pos/i17394b/_1.scala

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package example:
2+
def xd: Int = ???
3+
4+
package bar:
5+
trait A:
6+
def foo: String = ???
7+
8+
package object example extends bar.A:
9+
def foo(x: String): String = ???

tests/pos/i17394b/_2.scala

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//> using options -Wunused:imports
2+
3+
import example.{given, *}
4+
5+
@main def main = ()

0 commit comments

Comments
 (0)