We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 326fc3c commit f521a4dCopy full SHA for f521a4d
compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
@@ -740,10 +740,9 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
740
def sliceTopLevel(tree: Tree, cls: ClassSymbol)(using Context): List[Tree] = tree match {
741
case PackageDef(pid, stats) =>
742
val slicedStats = stats.flatMap(sliceTopLevel(_, cls))
743
- if (!slicedStats.isEmpty)
744
- cpy.PackageDef(tree)(pid, slicedStats) :: Nil
745
- else
746
- Nil
+ val isEffectivelyEmpty = slicedStats.forall(_.isInstanceOf[Import])
+ if isEffectivelyEmpty then Nil
+ else cpy.PackageDef(tree)(pid, slicedStats) :: Nil
747
case tdef: TypeDef =>
748
val sym = tdef.symbol
749
assert(sym.isClass)
0 commit comments