You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
@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.
I have a class:
In the repl:
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:
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
The text was updated successfully, but these errors were encountered: