Skip to content

Fix #3000: Do not flatten across packages #3001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 22, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/Flatten.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,20 @@ class Flatten extends MiniPhaseTransform with SymTransformer { thisTransform =>
else ref
}

private val liftedDefs = new mutable.ListBuffer[Tree]
private var liftedDefs = new mutable.ListBuffer[Tree]

private lazy val liftedDefsQueue = mutable.Stack.empty.asInstanceOf[mutable.Stack[mutable.ListBuffer[Tree]]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mutable.Stack.empty[mutable.ListBuffer[Tree]]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


override def prepareForPackageDef(tree: PackageDef)(implicit ctx: Context) = {
liftedDefsQueue.push(liftedDefs)
liftedDefs = new mutable.ListBuffer[Tree]
this
}

override def transformPackageDef(tree: PackageDef)(implicit ctx: Context, info: TransformerInfo) = {
liftedDefs = liftedDefsQueue.pop()
tree
}

private def liftIfNested(tree: Tree)(implicit ctx: Context, info: TransformerInfo) =
if (ctx.owner is Package) tree
Expand Down
5 changes: 5 additions & 0 deletions tests/pos/i3000.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Foo {
new Object { }
}

package bar { }