From fe5bd09861994734bc394813d069ea40c89d39de Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 2 Mar 2016 22:02:15 +1000 Subject: SI-9546 Fix regression in rewrite of case apply to constructor call In SI-9425, I disabled the rewrite of `CaseClass.apply(x)` to `new CaseClass(x)` if the constructor was was less accessible than the apply method. This solved a problem with spurious "constructor cannot be accessed" errors during refchecks for case classes with non-public constructors. However, for polymorphic case classes, refchecks was persistent, and even after refusing to transform the `TypeApply` within: CaseClass.apply[String]("") It *would* try again to transform the enclosing `Select`, a code path only intended for monomorphic case classes. The tree has a `PolyType`, which foiled the newly added accessibility check. I've modified the call to `isSimpleCaseApply` from the transform of `Select` nodes to exclude polymorphic apply's from being considered twice. --- test/files/run/t9546.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/files/run/t9546.scala (limited to 'test') diff --git a/test/files/run/t9546.scala b/test/files/run/t9546.scala new file mode 100644 index 0000000000..7016881084 --- /dev/null +++ b/test/files/run/t9546.scala @@ -0,0 +1,13 @@ +package foo { + case class Opt[A] private[foo](val get: A) extends AnyVal + object Opt { + def mkOpt = Opt("") + } +} + +object Test { + def main(args: Array[String]): Unit = { + foo.Opt.mkOpt + } +} + -- cgit v1.2.3