Permalink
Browse files

Revert "SI-6601 Publicise derived value contstructor after pickler"

This reverts commit b07228a.

The remedy was far worse than the disease:

    % cat sandbox/test.scala
    class V private (val a: Any) extends AnyVal

    % RUNNER=scalac scala-hash b07228a sandbox/test.scala
    [info] b07228a => /Users/jason/usr/scala-v2.10.0-256-gb07228a

    % scala-hash b07228a
    [info] b07228a => /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 <console>
    scala.reflect.internal.Types$TypeError: constructor V in class V cannot be accessed in object $iw
  • Loading branch information...
1 parent 2fa859e commit 172f3f68200a0bdc6c7f30547f269899cbbdcf98 @retronym retronym committed Jan 26, 2013
@@ -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)
@@ -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")
@@ -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
@@ -1,3 +0,0 @@
-class AccessPrivateConstructor {
- new PrivateConstructor("") // Scalac should forbid accessing to the private constructor!
-}
@@ -1 +0,0 @@
-class PrivateConstructor private(val s: String) extends AnyVal

0 comments on commit 172f3f6

Please sign in to comment.