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

DelayedInit: Reflective call fails while using default arguments #6557

Closed
scabug opened this issue Oct 22, 2012 · 7 comments
Closed

DelayedInit: Reflective call fails while using default arguments #6557

scabug opened this issue Oct 22, 2012 · 7 comments

Comments

@scabug
Copy link

scabug commented Oct 22, 2012

While using reflective calls in Scala 2.10-M7 (Eclipse Scala-IDE) I have found the following behaviour:

import scala.language.reflectiveCalls

trait A {
  val x: Int
  val y: Double
  val z: String
}

val A = new {
  def apply(_x: Int = 0, _y: Double = 0.0, _z: String = "") = new A {
    val x = _x
    val y = _y
    val z = _z
  }
}
  
assert(A(_x = 1).x == 1)               // OK
assert(A(1).x == 1)                    // OK
assert(A(_x = 1, _y = 1.0).x == 1)     // OK
assert(A(1, 1.0).x == 1)               // OK
assert(A(_y = 1.0).y == 1.0)           // ERROR
assert(A(_y = 1.0, _z = "1").z == "1") // ERROR
assert(A(_z = "1").z == "1")           // ERROR

The arised error is an "IllegalAccessError: tried to access field *.reflParams$Cache_ from class *". It seems this error occurs every time that I invoke the apply method while setting a value for an argument and letting a previous one to use the default.

@scabug
Copy link
Author

scabug commented Oct 22, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6557?orig=1
Reporter: Jesús López González (jlg)
Affected Versions: 2.10.0-M7

@scabug
Copy link
Author

scabug commented Oct 22, 2012

Jesús López González (jlg) said:
As I mentioned in the 'Environment' this example works fine in REPL. Moreover, it seems it only happens when extending the App trait.

@scabug
Copy link
Author

scabug commented Oct 22, 2012

@paulp said:
Oh, I wish I'd seen your comment. Yes, this is yet another bug in DelayedInit, which I've pretty much had it with. It gets pretty old having to double check every single reported bug with and without a main method to avoid the wild goose chases.

@scabug
Copy link
Author

scabug commented Oct 23, 2012

Jesús López González (jlg) said:
I posted the comment just when I noticed it. The thing is that I am pretty new reporting bugs :) I'll take it into account for the next time.

@scabug
Copy link
Author

scabug commented Dec 13, 2012

@adriaanm said:
(Pushing reflection bugs to 2.11 to aid scheduling -- as it's experimental in 2.10.x, it shouldn't influence 2.10's schedule. They may be fixed earlier, of course.)

@SethTisue
Copy link
Member

DelayedInit is deprecated

@lrytz
Copy link
Member

lrytz commented Mar 7, 2018

I couldn't reproduce it

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

3 participants