Skip to content

Inliner doesn't cope with private[this] vars #6213

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

Closed
scabug opened this issue Aug 9, 2012 · 4 comments
Closed

Inliner doesn't cope with private[this] vars #6213

scabug opened this issue Aug 9, 2012 · 4 comments
Milestone

Comments

@scabug
Copy link

scabug commented Aug 9, 2012

The following change that just got merged:
scala/scala#1095

introduced marking fields accessed by @inline method.

Now, it seems like inliner doesn't cope well with private[this] fields.

Apply the following patch to the test-case:

diff --git a/test/files/pos/inline-access-levels/A_1.scala b/test/files/pos/inline-access-levels/A_1.scala
index 479fe0f..db788cb 100644
--- a/test/files/pos/inline-access-levels/A_1.scala
+++ b/test/files/pos/inline-access-levels/A_1.scala
@@ -3,8 +3,14 @@ package test
 object A {
 
   private var x: Int = 0
+  // translation at bytecode level is different for private[this] so we need to test both
+  private[this] var y: Int = 0
 
   @inline def actOnX(f: Int => Int) = {
     x = f(x)
   }
+
+  @inline def actOnY(f: Int => Int) = {
+    y = f(y)
+  }
 }
diff --git a/test/files/pos/inline-access-levels/Test_2.scala b/test/files/pos/inline-access-levels/Test_2.scala
index 12c9eb5..7c85642 100644
--- a/test/files/pos/inline-access-levels/Test_2.scala
+++ b/test/files/pos/inline-access-levels/Test_2.scala
@@ -3,9 +3,8 @@ package test
 object Test {
 
   def main(args: Array[String]) {
-
     A.actOnX(_ + 1)
-
+    A.actOnY(_ + 2)
   }
 
 }

and now see it fail:

./partest files/pos/inline-access-levels

Testing individual files
testing: [...]/files/pos/inline-access-levels                         [FAILED]
1 of 1 tests failed (elapsed time: 00:00:03)
@scabug
Copy link
Author

scabug commented Aug 9, 2012

@scabug
Copy link
Author

scabug commented Jan 11, 2013

@gkossakowski said:
I'm not planning to work on inliner at the moment. Reassigning to James who might have a look.

This is not very high priority ticket at the moment.

@SethTisue
Copy link
Member

closing old backend tickets, since the back end was completely replaced in Scala 2.12. reopen if you demonstrate this is still relevant in current Scala

@som-snytt
Copy link

Now it's just a public field, what could go wrong?

public int test$B$$x;

Judging from the previous comment that this was supposed to be closed, but I can't find the scolded label.

I'll try to summon the strength to augment the test.

@SethTisue SethTisue removed this from the Backlog milestone Nov 15, 2019
@lrytz lrytz added this to the 2.12.0 milestone Nov 18, 2019
@lrytz lrytz reopened this Nov 18, 2019
@lrytz lrytz closed this as completed Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants