Skip to content

Commit

Permalink
These tests represent a big TODO. We currently have a bit of logic that
Browse files Browse the repository at this point in the history
attempts to protect the compiler from generating byte code that uses
'this' during a call to a super constructor. There are two problems with
that code. First, it happens early before delambdafication has a chance
to simplify the code. Second, it's incomplete and it's easy to write
code that sneaks past the verification but produces broken byte code.
The conclusion from the team is that that logic needs to be pushed into
a much later phase, possibly after going to the ICode/ASM IR. But that
change is outside the scope of this work so for now these tests are
simply forced to run only with inline delambdafication.
  • Loading branch information
James Iry committed Aug 29, 2013
1 parent 35033ad commit bf1ba25
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/files/neg/t6231.flags
@@ -0,0 +1 @@
-Ydelambdafy:inline
1 change: 1 addition & 0 deletions test/files/neg/t6666.flags
@@ -0,0 +1 @@
-Ydelambdafy:inline

This comment has been minimized.

Copy link
@retronym

retronym Aug 30, 2013

Member

This patch almost gets this test working again. (Same number of errors but different messages.)

I know this stuff is pretty hacky, but it might help until we figure out the best approach.

diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/L
index ce495ca..1b0d371 100644
--- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
+++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
@@ -342,7 +342,12 @@ abstract class LambdaLift extends InfoTransform {
         currentUnit.error(curTree.pos, msg)
       }
       val qual =
-        if (clazz == currentClass) gen.mkAttributedThis(clazz)
+        if (clazz == currentClass) {
+          if (currentOwner.isMethod && currentOwner.name.startsWith(tpnme.ANON_FUN_NAME) && isUnderConstructio
+            prematureSelfReference()
+            EmptyTree
+          } else gen.mkAttributedThis(clazz)
+        }
         else {
1 change: 1 addition & 0 deletions test/files/neg/t6666c.flags
@@ -0,0 +1 @@
-Ydelambdafy:inline

1 comment on commit bf1ba25

@scala-jenkins
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Job pr-scala failed for bf1ba25 Took 4 min. (results):


To retry exactly this commit (if the failure was spurious), comment "PLS REBUILD/pr-scala@bf1ba254a46fe81e3015901d527b1e8677e4050e" on PR 2887.NOTE: new commits are rebuilt automatically as they appear. There's no need to force a rebuild if you're updating the PR.

Please sign in to comment.