Skip to content
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

Access widening for the Inliner in SuperAccessors results in private members appearing public on unpickling #6608

Closed
scabug opened this issue Nov 3, 2012 · 5 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Nov 3, 2012

Followup to #6562.

Private members will appear as public in the scalap output, and IntelliJ will offer these as autocompletion options.

Test.scala

package sandbox

class C {
  private val x: Any = 1
  @inline def foo = x
}

Scalap output:

package sandbox
class C extends java.lang.Object {
  def this() = { /* compiled code */ }
  val x : scala.Any = { /* compiled code */ }
  @scala.inline
  def foo : scala.Any = { /* compiled code */ }
}

Another fun angle on the problem:

ticket/6562-3 ~/code/scala cat sandbox/test.scala 
package sandbox

class C {
  private val x: Any = 1
  @inline def foo = x
}
ticket/6562-3 ~/code/scala cat sandbox/test_2.scala 
package sandbox

object Test {
  new C().sandbox$C$$x
}
ticket/6562-3 ~/code/scala /Users/jason/usr/scala-v2.10.0-RC1-15-g2c55424/pack/bin/scalac -classpath . -d . sandbox/test.scala  && /Users/jason/usr/scala-v2.10.0-RC1-15-g2c55424/pack/bin/scalac -classpath . -d . sandbox/test_2.scala 
ticket/6562-3 ~/code/scala 
@scabug
Copy link
Author

@scabug scabug commented Nov 3, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6608?orig=1
Reporter: @retronym
Affected Versions: 2.10.0-RC1

@scabug
Copy link
Author

@scabug scabug commented Mar 11, 2013

@scabug
Copy link
Author

@scabug scabug commented Aug 23, 2014

@retronym said:
Here's a related bug that looks to be a consequence of this behaviour:

% tail test/files/run/private-module-accessor-meets-inline/*.scala
==> test/files/run/private-module-accessor-meets-inline/A_1.scala <==
  private case class C()
  // or,       class C(x: Any = 0)

  final class Context {
    @inline final def kaboom(): Unit = {
      C // reference to synthetic companion
        // or, `new C(/*default arg*/)` in the second variant
    }
  }
}

==> test/files/run/private-module-accessor-meets-inline/B_2.scala <==
object Test {
  def main(args: Array[String]): Unit = {
    val analyzer = new Analyzer {}
    val context = new analyzer.Context()
    context.kaboom()
  }
}

% pt --verbose test/files/run/private-module-accessor-meets-inline/
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128M; support was removed in 8.0
Option '--all' not recognized.
Partest version:
Compiler under test: $baseDir/scala-compiler.jar
Scala version is:    Scala compiler version 2.11.2-20140804-175042-ca9f64dfa2 -- Copyright 2002-2013, LAMP/EPFL
Scalac options are:
Compilation Path:    $baseDir/scala-library.jar:$baseDir/scala-reflect.jar:$baseDir/scala-compiler.jar:$baseDir/scalap.jar:$baseDir/scala-actors.jar:/Users/jason/.m2/repository/org/scala-lang/modules/scala-partest_2.11/1.0.0/scala-partest_2.11-1.0.0.jar:/Users/jason/.m2/repository/org/apache/ant/ant/1.8.4/ant-1.8.4.jar:/Users/jason/.m2/repository/org/apache/ant/ant-launcher/1.8.4/ant-launcher-1.8.4.jar:/Users/jason/.m2/repository/com/googlecode/java-diff-utils/diffutils/1.3.0/diffutils-1.3.0.jar:/Users/jason/.m2/repository/org/scala-sbt/test-interface/1.0/test-interface-1.0.jar:/Users/jason/.m2/repository/org/scala-lang/modules/scala-xml_2.11/1.0.2/scala-xml_2.11-1.0.2.jar:/Users/jason/.m2/repository/org/scala-lang/modules/scala-parser-combinators_2.11/1.0.1/scala-parser-combinators_2.11-1.0.1.jar:/Users/jason/.m2/repository/org/scalacheck/scalacheck_2.11/1.11.3/scalacheck_2.11-1.11.3.jar:$baseDir/scala-partest-extras.jar:$baseDir/scala-partest-javaagent.jar:$sourceDir/lib/annotations.jar:$sourceDir/lib/enums.jar:$sourceDir/lib/genericNest.jar:$sourceDir/lib/jsoup-1.3.1.jar:$sourceDir/lib/macro210.jar:$sourceDir/lib/methvsfield.jar:$sourceDir/lib/nest.jar:$sourceDir/lib/scalacheck.jar
Java binaries in:    /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/bin
Java runtime is:     Java HotSpot(TM) 64-Bit Server VM (build 25.0-b66, mixed mode)
Java options are:    -Xmx1024M -Xms64M -XX:MaxPermSize=128M
baseDir:             /Users/jason/code/scala/build/pack/lib
sourceDir:           /Users/jason/code/scala/test/files

Selected 1 tests drawn from specified tests

# starting 1 test in run
% scalac private-module-accessor-meets-inline/A_1.scala
% scalac private-module-accessor-meets-inline/B_2.scala
!! 1 - run/private-module-accessor-meets-inline  [non-zero exit code]
# 0/1 passed, 1 failed in run

##### Transcripts from failed tests #####

# partest /Users/jason/code/scala/test/files/run/private-module-accessor-meets-inline
% scalac private-module-accessor-meets-inline/A_1.scala
% scalac private-module-accessor-meets-inline/B_2.scala
% java \
  -Xmx1024M \
  -Xms64M \
  -XX:MaxPermSize=128M \
  -classpath \
  /Users/jason/code/scala/test/files/run/private-module-accessor-meets-inline-run.obj:/Users/jason/code/scala/build/pack/lib/scala-library.jar:/Users/jason/code/scala/build/pack/lib/scala-reflect.jar:/Users/jason/code/scala/build/pack/lib/scala-compiler.jar:/Users/jason/code/scala/build/pack/lib/scalap.jar:/Users/jason/code/scala/build/pack/lib/scala-actors.jar:/Users/jason/.m2/repository/org/scala-lang/modules/scala-partest_2.11/1.0.0/scala-partest_2.11-1.0.0.jar:/Users/jason/.m2/repository/org/apache/ant/ant/1.8.4/ant-1.8.4.jar:/Users/jason/.m2/repository/org/apache/ant/ant-launcher/1.8.4/ant-launcher-1.8.4.jar:/Users/jason/.m2/repository/com/googlecode/java-diff-utils/diffutils/1.3.0/diffutils-1.3.0.jar:/Users/jason/.m2/repository/org/scala-sbt/test-interface/1.0/test-interface-1.0.jar:/Users/jason/.m2/repository/org/scala-lang/modules/scala-xml_2.11/1.0.2/scala-xml_2.11-1.0.2.jar:/Users/jason/.m2/repository/org/scala-lang/modules/scala-parser-combinators_2.11/1.0.1/scala-parser-combinators_2.11-1.0.1.jar:/Users/jason/.m2/repository/org/scalacheck/scalacheck_2.11/1.11.3/scalacheck_2.11-1.11.3.jar:/Users/jason/code/scala/build/pack/lib/scala-partest-extras.jar:/Users/jason/code/scala/build/pack/lib/scala-partest-javaagent.jar:/Users/jason/code/scala/test/files/lib/annotations.jar:/Users/jason/code/scala/test/files/lib/enums.jar:/Users/jason/code/scala/test/files/lib/genericNest.jar:/Users/jason/code/scala/test/files/lib/jsoup-1.3.1.jar:/Users/jason/code/scala/test/files/lib/macro210.jar:/Users/jason/code/scala/test/files/lib/methvsfield.jar:/Users/jason/code/scala/test/files/lib/nest.jar:/Users/jason/code/scala/test/files/lib/scalacheck.jar \
  -Dfile.encoding=UTF-8 \
  -Djava.library.path=/Users/jason/code/scala/test/files/run \
  -Dpartest.output=/Users/jason/code/scala/test/files/run/private-module-accessor-meets-inline-run.obj \
  -Dpartest.lib=/Users/jason/code/scala/build/pack/lib/scala-library.jar \
  -Dpartest.reflect=/Users/jason/code/scala/build/pack/lib/scala-reflect.jar \
  -Dpartest.cwd=/Users/jason/code/scala/test/files/run \
  -Dpartest.test-path=/Users/jason/code/scala/test/files/run/private-module-accessor-meets-inline \
  -Dpartest.testname=private-module-accessor-meets-inline \
  -Djavacmd=java \
  -Djavaccmd=/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/javac \
  -Duser.language=en \
  -Duser.country=US \
  scala.tools.nsc.MainGenericRunner \
  -usejavacp \
  Test \
  jvm > private-module-accessor-meets-inline-run.log
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128M; support was removed in 8.0
java.lang.AbstractMethodError: Test$$anon$1.Analyzer$$C()LAnalyzer$C$;
	at Analyzer$Context.kaboom(A_1.scala:7)
	at Test$.main(B_2.scala:5)
	at Test.main(B_2.scala)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at scala.reflect.internal.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:68)
	at scala.reflect.internal.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
	at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:99)
	at scala.reflect.internal.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:68)
	at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:99)
	at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:22)
	at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:39)
	at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:29)
	at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:39)
	at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:65)
	at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:87)
	at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:98)
	at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:103)
	at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)


# Failed test paths (this command will update checkfiles)
test/partest --update-check \
  /Users/jason/code/scala/test/files/run/private-module-accessor-meets-inline

0/1 passed, 1 failed (elapsed time: 00:00:03)

@scabug
Copy link
Author

@scabug scabug commented Jul 20, 2015

@SethTisue said:
@retronym 2236 was merged, should this ticket be closed?

@scabug
Copy link
Author

@scabug scabug commented Jul 20, 2015

@retronym said:
AFAICR, yes, I think that is sufficient.

@scabug scabug closed this Jul 20, 2015
@scabug scabug added this to the 2.11.0-M3 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants