Skip to content

Fixes for DelayedInit classes capturing values#5423

Merged
adriaanm merged 2 commits intoscala:2.12.0from
lrytz:sd229
Sep 28, 2016
Merged

Fixes for DelayedInit classes capturing values#5423
adriaanm merged 2 commits intoscala:2.12.0from
lrytz:sd229

Conversation

@lrytz
Copy link
Member

@lrytz lrytz commented Sep 27, 2016

@scala-jenkins scala-jenkins added this to the 2.12.0-RC2 milestone Sep 27, 2016
@lrytz lrytz force-pushed the sd229 branch 2 times, most recently from dc37506 to 07f51b1 Compare September 27, 2016 20:36
@retronym
Copy link
Member

retronym commented Sep 27, 2016

https://scala-ci.typesafe.com/job/scala-2.12.0-validate-test/71/consoleFull

ok  131 - run/existentials3-old.scala             
Exception in thread "Thread-29" java.io.EOFException
    at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2626)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1321)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
    at sbt.React.react(ForkTests.scala:114)
    at sbt.ForkTests$$anonfun$mainTestTask$1$Acceptor$2$.run(ForkTests.scala:74)
    at java.lang.Thread.run(Thread.java:745)
[error] Error: Total 0, Failed 0, Errors 0, Passed 0
[error] Error during tests:
[error]     Running java with options -classpath /home/jenkins/workspace/scala-2.12.0-validate-test/target/test/it-classes:/home/jenkins/workspace/scala-2.12.0-validate-test/build/quick/classes/test:/home/jenkins/workspace/scala-2.12.0-validate-test/build/quick/classes/compiler:/home/jenkins/workspace/scala-2.12.0-validate-test/build/quick/classes/library:/home/jenkins/workspace/scala-2.12.0-validate-test/build/quick/classes/reflect:/home/jenkins/workspace/scala-2.12.0-validate-test/build/quick/classes/interactive:/home/jenkins/workspace/scala-2.12.0-validate-test/build/quick/classes/repl-jline-embedded:/home/jenkins/workspace/scala-2.12.0-validate-test/build/quick/classes/repl-jline:/home/jenkins/workspace/scala-2.12.0-validate-test/build/quick/classes/repl:/home/jenkins/workspace/scala-2.12.0-validate-test/build/quick/classes/scalap:/home/jenkins/workspace/scala-2.12.0-validate-test/build/quick/classes/partest-extras:/home/jenkins/workspace/scala-2.12.0-validate-test/build/pack/lib/scala-partest-javaagent.jar:/home/jenkins/workspace/scala-2.12.0-validate-test/build/quick/classes/scaladoc:/home/jenkins/.ivy2/cache/org.apache.ant/ant/jars/ant-1.9.4.jar:/home/jenkins/.ivy2/cache/org.apache.ant/ant-launcher/jars/ant-launcher-1.9.4.jar:/home/jenkins/.ivy2/cache/org.scala-lang.modules/scala-asm/bundles/scala-asm-5.1.0-scala-1.jar:/home/jenkins/.ivy2/cache/org.scala-lang.modules/scala-xml_2.12.0-RC1/bundles/scala-xml_2.12.0-RC1-1.0.5.jar:/home/jenkins/.ivy2/cache/jline/jline/jars/jline-2.14.1.jar:/home/jenkins/.ivy2/cache/org.scala-lang.modules/scala-partest_2.12.0-RC1/jars/scala-partest_2.12.0-RC1-1.0.17.jar:/home/jenkins/.ivy2/cache/com.googlecode.java-diff-utils/diffutils/jars/diffutils-1.3.0.jar:/home/jenkins/.ivy2/cache/org.scala-sbt/test-interface/jars/test-interface-1.0.jar:/home/jenkins/.ivy2/cache/org.scala-lang.scala-sha-bootstrap.test.files.lib/jsoup-1.3.1/jars/jsoup-1.3.1-346d3dff4088839d6b4d163efa2892124039d216.jar:/home/jenkins/.ivy2/cache/org.scala-lang.scala-sha-bootstrap.test.files.lib/macro210/jars/macro210-3794ec22d9b27f2b179bd34e9b46db771b934ec3.jar:/home/jenkins/.ivy2/cache/org.scala-lang.scala-sha-bootstrap.test.files.lib/enums/jars/enums-981392dbd1f727b152cd1c908c5fce60ad9d07f7.jar:/home/jenkins/.ivy2/cache/org.scala-lang.scala-sha-bootstrap.test.files.lib/annotations/jars/annotations-02fe2ed93766323a13f22c7a7e2ecdcd84259b6c.jar:/home/jenkins/.ivy2/cache/org.scala-lang.scala-sha-bootstrap.test.files.lib/genericNest/jars/genericNest-b1ec8a095cec4902b3609d74d274c04365c59c04.jar:/home/jenkins/.ivy2/cache/org.scala-lang.scala-sha-bootstrap.test.files.lib/methvsfield/jars/methvsfield-be8454d5e7751b063ade201c225dcedefd252775.jar:/home/jenkins/.ivy2/cache/org.scala-lang.scala-sha-bootstrap.test.files.lib/nest/jars/nest-cd33e0a0ea249eb42363a2f8ba531186345ff68c.jar:/home/jenkins/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/test-agent-0.13.11.jar:/home/jenkins/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/test-interface-1.0.jar sbt.ForkMain 46622
 failed with exit code 137
Partest version:     
Compiler under test: $baseDir/compiler
Scala version is:    Scala compiler version 2.12.0-20160927-223632-07f51b1 -- Copyright 2002-2016, LAMP/EPFL
Scalac options are:  -opt:l:classpath
Compilation Path:    /home/jenkins/workspace/scala-2.12.0-validate-test/target/test/it-classes:$baseDir/test:$baseDir/compiler:$baseDir/library:$baseDir/reflect:$baseDir/interactive:$baseDir/repl-jline-embedded:$baseDir/repl-jline:$baseDir/repl:$baseDir/scalap:$baseDir/partest-extras:/home/jenkins/workspace/scala-2.12.0-validate-test/build/pack/lib/scala-partest-javaagent.jar:$baseDir/scaladoc:/home/jenkins/.ivy2/cache/org.apache.ant/ant/jars/ant-1.9.4.jar:/home/jenkins/.ivy2/cache/org.apache.ant/ant-launcher/jars/ant-launcher-1.9.4.jar:/home/jenkins/.ivy2/cache/org.scala-lang.modules/scala-asm/bundles/scala-asm-5.1.0-scala-1.jar:/home/jenkins/.ivy2/cache/org.scala-lang.modules/scala-xml_2.12.0-RC1/bundles/scala-xml_2.12.0-RC1-1.0.5.jar:/home/jenkins/.ivy2/cache/jline/jline/jars/jline-2.14.1.jar:/home/jenkins/.ivy2/cache/org.scala-lang.modules/scala-partest_2.12.0-RC1/jars/scala-partest_2.12.0-RC1-1.0.17.jar:/home/jenkins/.ivy2/cache/com.googlecode.java-diff-utils/diffutils/jars/diffutils-1.3.0.jar:/home/jenkins/.ivy2/cache/org.scala-sbt/test-interface/jars/test-interface-1.0.jar:/home/jenkins/.ivy2/cache/org.scala-lang.scala-sha-bootstrap.test.files.lib/jsoup-1.3.1/jars/jsoup-1.3.1-346d3dff4088839d6b4d163efa2892124039d216.jar:/home/jenkins/.ivy2/cache/org.scala-lang.scala-sha-bootstrap.test.files.lib/macro210/jars/macro210-3794ec22d9b27f2b179bd34e9b46db771b934ec3.jar:/home/jenkins/.ivy2/cache/org.scala-lang.scala-sha-bootstrap.test.files.lib/enums/jars/enums-981392dbd1f727b152cd1c908c5fce60ad9d07f7.jar:/home/jenkins/.ivy2/cache/org.scala-lang.scala-sha-bootstrap.test.files.lib/annotations/jars/annotations-02fe2ed93766323a13f22c7a7e2ecdcd84259b6c.jar:/home/jenkins/.ivy2/cache/org.scala-lang.scala-sha-bootstrap.test.files.lib/genericNest/jars/genericNest-b1ec8a095cec4902b3609d74d274c04365c59c04.jar:/home/jenkins/.ivy2/cache/org.scala-lang.scala-sha-bootstrap.test.files.lib/methvsfield/jars/methvsfield-be8454d5e7751b063ade201c225dcedefd252775.jar:/home/jenkins/.ivy2/cache/org.scala-lang.scala-sha-bootstrap.test.files.lib/nest/jars/nest-cd33e0a0ea249eb42363a2f8ba531186345ff68c.jar:/home/jenkins/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/test-agent-0.13.11.jar:/home/jenkins/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.11/test-interface-1.0.jar
Java binaries in:    /usr/lib/jvm/java-8-openjdk-amd64/jre/bin
Java runtime is:     OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
Java options are:    -Xmx1024M -Xms64M -XX:MaxPermSize=128M
baseDir:             /home/jenkins/workspace/scala-2.12.0-validate-test/build/quick/classes
sourceDir:           /home/jenkins/workspace/scala-2.12.0-validate-test/test/files

😕

@retronym
Copy link
Member

/rebuild

@retronym
Copy link
Member

image

When a class captures an outer value, a field for that value is created
in the class. The class also gets a constructor parameter for the
captured value, the constructor will assign the field.

LambdaLift re-writes accesses to the local value (Ident trees) to the
field. However, if the statement accessing the local value will end up
inside the constructor, the access is re-written to the constructor
parameter instead. This is the case for constructor statements:

    class C {
      {
        println(capturedLocal)
      }
    }

If C extends DelayedInit, the statement does not end up in C's
constructor, but into a new synthetic method. The access to
`capturedLocal` needs to be re-written to the field instead of the
constructor parameter.

LambdaLift takes the decision (field or constructor parameter) based on
the owner chain of `currentOwner`. For the constructor statement block,
the owner is a local dummy, for which `logicallyEnclosingMember` returns
the constructor symbol.

This commit introduces a special case in LambdaLift for local dummies
of DelayedInit subclasses: instead of the constructor, we use a
temporary symbol representing the synthetic method holding the
initializer statements.
Constructors rewrites references to parameter accessor methods in the
constructor to references to parameters. It avoids doing so for
subclasses of DelayedInit.

This commit makes sure the rewrite does not happen for the $outer
paramter, a case that was simply forgotten.
@lrytz
Copy link
Member Author

lrytz commented Sep 28, 2016

the rebuild helped, now the only failure was due to a missing .check file

@schmitch
Copy link

schmitch commented Sep 28, 2016

Just wanted to say that I ran the Play Test Suite against 2.12.0-ad6bf30-SNAPSHOT via:

resolvers += "pr" at "https://scala-ci.typesafe.com/artifactory/scala-pr-validation-snapshots/",
scalaVersion := "2.12.0-ad6bf30-SNAPSHOT",
scalaBinaryVersion := "2.12.0-RC1",

And it will pass all the tests. (except scripted that can't be run due to dependency resolution)

@adriaanm
Copy link
Contributor

LGTM!

Ah, the joys of DelayedInit feature interactions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants