From bf6a4f8f30c02f9e13cfdc530ec986524fd317f0 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Thu, 15 Dec 2022 16:18:35 +0000 Subject: [PATCH] Fix -Ytest-pickler bug with private[this] --- compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala | 2 +- compiler/src/dotty/tools/dotc/typer/Applications.scala | 1 + tests/pos/test-pickler-private-this.scala | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 tests/pos/test-pickler-private-this.scala diff --git a/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala b/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala index 462148a5c758..4a4eee263e70 100644 --- a/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala +++ b/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala @@ -157,7 +157,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds, type This = OrderingConstraint /** A new constraint with given maps and given set of hard typevars */ - def newConstraint( // !!! Dotty problem: Making newConstraint `private` causes -Ytest-pickler failure. + private def newConstraint( boundsMap: ParamBounds = this.boundsMap, lowerMap: ParamOrdering = this.lowerMap, upperMap: ParamOrdering = this.upperMap, diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 20ae81a74655..e3dac13b2e84 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -272,6 +272,7 @@ object Applications { else def selectGetter(qual: Tree): Tree = val getterDenot = qual.tpe.member(getterName) + .accessibleFrom(qual.tpe.widenIfUnstable) // to reset Local if (getterDenot.exists) qual.select(TermRef(qual.tpe, getterName, getterDenot)) else EmptyTree if !meth.isClassConstructor then diff --git a/tests/pos/test-pickler-private-this.scala b/tests/pos/test-pickler-private-this.scala new file mode 100644 index 000000000000..3a1282fbe6a2 --- /dev/null +++ b/tests/pos/test-pickler-private-this.scala @@ -0,0 +1,3 @@ +class Test: + def callMeth(test: Test) = test.meth(-1) + private def meth(foo: Int, bar: Int = 1) = foo + bar