Skip to content

Commit f521a4d

Browse files
committed
Avoid pickling nested packages with only imports
1 parent 326fc3c commit f521a4d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,10 +740,9 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
740740
def sliceTopLevel(tree: Tree, cls: ClassSymbol)(using Context): List[Tree] = tree match {
741741
case PackageDef(pid, stats) =>
742742
val slicedStats = stats.flatMap(sliceTopLevel(_, cls))
743-
if (!slicedStats.isEmpty)
744-
cpy.PackageDef(tree)(pid, slicedStats) :: Nil
745-
else
746-
Nil
743+
val isEffectivelyEmpty = slicedStats.forall(_.isInstanceOf[Import])
744+
if isEffectivelyEmpty then Nil
745+
else cpy.PackageDef(tree)(pid, slicedStats) :: Nil
747746
case tdef: TypeDef =>
748747
val sym = tdef.symbol
749748
assert(sym.isClass)

0 commit comments

Comments
 (0)