Skip to content

Fix #8801: Update registeredCompanion when mapping symbols #8812

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 2 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import util.Spans._
import DenotTransformers._
import StdNames._
import NameOps._
import transform.SymUtils._
import NameKinds.LazyImplicitName
import ast.tpd
import tpd.{Tree, TreeProvider, TreeOps}
Expand Down Expand Up @@ -351,6 +352,8 @@ trait Symbols { thisCtx: Context =>
info = completer,
privateWithin = ttmap1.mapOwner(odenot.privateWithin), // since this refers to outer symbols, need not include copies (from->to) in ownermap here.
annotations = odenot.annotations)
copy.registeredCompanion =
copy.registeredCompanion.subst(originals, copies)
}

copies.foreach(_.ensureCompleted()) // avoid memory leak
Expand Down
9 changes: 9 additions & 0 deletions tests/pos/i8801.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
object Foo:
locally {
case class Baz()
}

class Foo2 {
def foo(x: Any = 3, y: Any = 9): Any = x
val a = foo(y = { case class Bar(x: Int) }, x = ())
}