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 doesn't work when named arguments are supplied in a different order to defined #6481

Closed
scabug opened this issue Oct 6, 2012 · 6 comments

Comments

@scabug
Copy link

scabug commented Oct 6, 2012

I have a class:

abstract class foo(a: Int, b: Int) extends scala.DelayedInit {
  def delayedInit(x: => Unit) {
    println("delayed init");
    x
  }
}

In the repl:

scala> new foo(1, 2) { println("in here") }
delayed init:
in here
res14: foo = $anon$1@17c95b4c

As expected. It also works for foo(a = 1, b = 2). However, if I supply named arguments in a different order to the way they are defined, then I get:

scala> new foo(b = 2, a = 1) { println("in here") }
in here
res20: foo = $anon$1@1f8bd6f9

and the delayedInit method isn't invoked.

The real world application I have of this is in Specs, when defining an Around scope that takes named parameters that have default values defined, such as these in Play framework:

https://github.com/playframework/Play20/blob/master/framework/src/play-test/src/main/scala/play/api/test/Specs.scala

@scabug
Copy link
Author

scabug commented Oct 6, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6481?orig=1
Reporter: @jroper
Affected Versions: 2.9.2

@scabug
Copy link
Author

scabug commented Oct 8, 2012

@paulp said:
For anyone looking to fix this, the situation is captured by my comment in Constructors:

      /** XXX This is not corect: remainingConstrStats.nonEmpty excludes too much,
       *  but excluding it includes too much.  The constructor sequence being mimicked
       *  needs to be reproduced with total fidelity.
       *
       *  See test case files/run/bug4680.scala, the output of which is wrong in many
       *  particulars.
       */

Specifically, "remainingConstrStats.nonEmpty excludes too much." I wouldn't expect any fixes to delayedInit though, certainly not from me.

@scabug
Copy link
Author

scabug commented Nov 19, 2012

Henry Story (bblfish) said:
This bug has an effect on Play 2.1 http://play.lighthouseapp.com/projects/82401/tickets/860-21-rc1-playapitestwithserver-fails-when-port-is-given

@scabug
Copy link
Author

scabug commented Mar 15, 2013

@adriaanm said:
Un-assigning to foster work stealing, as announced in https://groups.google.com/forum/?fromgroups=#!topic/scala-internals/o8WG4plpNkw

@scabug
Copy link
Author

scabug commented May 30, 2013

@scabug
Copy link
Author

scabug commented May 30, 2013

@retronym said:
scala/scala#2611

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

2 participants