From 172f3f68200a0bdc6c7f30547f269899cbbdcf98 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sat, 26 Jan 2013 08:04:47 +0100 Subject: [PATCH] Revert "SI-6601 Publicise derived value contstructor after pickler" This reverts commit b07228aebe7aa620af45a681ef60d945ffc65665. The remedy was far worse than the disease: % cat sandbox/test.scala class V private (val a: Any) extends AnyVal % RUNNER=scalac scala-hash b07228aebe sandbox/test.scala [info] b07228aebe => /Users/jason/usr/scala-v2.10.0-256-gb07228a % scala-hash b07228aebe [info] b07228aebe => /Users/jason/usr/scala-v2.10.0-256-gb07228a Welcome to Scala version 2.10.1-20130116-230935-b07228aebe (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_27). Type in expressions to have them evaluated. Type :help for more information. scala> def foo(v: V) = v.a == v.a exception when typing v.a().==(v.a())/class scala.reflect.internal.Trees$Apply constructor V in class V cannot be accessed in object $iw in file scala.reflect.internal.Types$TypeError: constructor V in class V cannot be accessed in object $iw --- src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala | 1 + src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 2 -- test/files/neg/t6601.check | 4 ---- test/files/neg/t6601/AccessPrivateConstructor_2.scala | 3 --- test/files/neg/t6601/PrivateConstructor_1.scala | 1 - 5 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 test/files/neg/t6601.check delete mode 100644 test/files/neg/t6601/AccessPrivateConstructor_2.scala delete mode 100644 test/files/neg/t6601/PrivateConstructor_1.scala diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala index 39e16c3f58b4..5318524870ef 100644 --- a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala +++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala @@ -144,6 +144,7 @@ abstract class ExtensionMethods extends Transform with TypingTransformers { wrap over other value classes anyway. checkNonCyclic(currentOwner.pos, Set(), currentOwner) */ extensionDefs(currentOwner.companionModule) = new mutable.ListBuffer[Tree] + currentOwner.primaryConstructor.makeNotPrivate(NoSymbol) super.transform(tree) } else if (currentOwner.isStaticOwner) { super.transform(tree) diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 969bb8acebae..5cea250eec35 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1686,8 +1686,6 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans val bridges = addVarargBridges(currentOwner) checkAllOverrides(currentOwner) checkAnyValSubclass(currentOwner) - if (currentOwner.isDerivedValueClass) - currentOwner.primaryConstructor makeNotPrivate NoSymbol // SI-6601, must be done *after* pickler! if (bridges.nonEmpty) deriveTemplate(tree)(_ ::: bridges) else tree case dc@TypeTreeWithDeferredRefCheck() => abort("adapt should have turned dc: TypeTreeWithDeferredRefCheck into tpt: TypeTree, with tpt.original == dc") diff --git a/test/files/neg/t6601.check b/test/files/neg/t6601.check deleted file mode 100644 index 1410e1b11a79..000000000000 --- a/test/files/neg/t6601.check +++ /dev/null @@ -1,4 +0,0 @@ -AccessPrivateConstructor_2.scala:2: error: constructor PrivateConstructor in class PrivateConstructor cannot be accessed in class AccessPrivateConstructor - new PrivateConstructor("") // Scalac should forbid accessing to the private constructor! - ^ -one error found diff --git a/test/files/neg/t6601/AccessPrivateConstructor_2.scala b/test/files/neg/t6601/AccessPrivateConstructor_2.scala deleted file mode 100644 index 816bc10d7945..000000000000 --- a/test/files/neg/t6601/AccessPrivateConstructor_2.scala +++ /dev/null @@ -1,3 +0,0 @@ -class AccessPrivateConstructor { - new PrivateConstructor("") // Scalac should forbid accessing to the private constructor! -} diff --git a/test/files/neg/t6601/PrivateConstructor_1.scala b/test/files/neg/t6601/PrivateConstructor_1.scala deleted file mode 100644 index f09d7ad06825..000000000000 --- a/test/files/neg/t6601/PrivateConstructor_1.scala +++ /dev/null @@ -1 +0,0 @@ -class PrivateConstructor private(val s: String) extends AnyVal