Can't get semantics of this loop in macro expanding - scala

I'm experimenting with Scala FastParsers library and I'm studying macro expanding of the following code:
val trueValue = "true".toCharArray
val falseValue = "false".toCharArray
object KParser1 {
import fastparsers.framework.implementations.FastParsersCharArray._
val kparser = FastParsersCharArray {
def func1: Parser[Any] = func1 | falseValue
}
}
Whole expanding is there but a piece of code from there really bothers me
while$2() {
if (inputpos$macro$2.$less(inputsize$macro$3).$amp$amp(input$macro$1(inputpos$macro$2).$eq$eq(' ').$bar$bar(input$macro$1(inputpos$macro$2).$eq$eq('\t')).$bar$bar(input$macro$1(inputpos$macro$2).$eq$eq('\n')).$bar$bar(input$macro$1(inputpos$macro$2).$eq$eq('\r'))))
{
inputpos$macro$2 = inputpos$macro$2.$plus(1);
while$2()
}
else
()
};
It looks like the code which skips whitespace from input stream but I can't infer what exactly is while$2: is it declared there as Unit => Unit and called automatically or is it some predefined function with type Unit => Any => Any?

It's just a loop. Compare:
scala> while (!done) println("working")
[[syntax trees at end of typer]] // <console>
package $line5 {
object $read extends scala.AnyRef {
def <init>(): $line5.$read.type = {
$read.super.<init>();
()
};
object $iw extends scala.AnyRef {
def <init>(): type = {
$iw.super.<init>();
()
};
import $line4.$read.$iw.$iw.done;
object $iw extends scala.AnyRef {
def <init>(): type = {
$iw.super.<init>();
()
};
private[this] val res0: Unit = while$1(){
if ($line4.$read.$iw.$iw.done.unary_!)
{
scala.this.Predef.println("working");
while$1()
}
else
()
};
<stable> <accessor> def res0: Unit = $iw.this.res0
}
}
}
}

Related

Run Macro to generate code from parent class in Scala

I have a macro that I use to generate some code to call methods dynamically. The macro is more complex than this, but for simplicity let's say it works something like this
def myMacro[T]: Seq[MethodName]
so than when called on
class Hello {
def one(a: Int, b: UserId): String = a.toString + b.id
def two(c: Option[Int]): String = ""
def three(d: Seq[Int], f: Set[Int]): String = ""
}
println(myMacro[Hello]) // Seq("one", "two", "three")
I need this macro to generate code for an internal framework we use at Candu, but I need to be able to call it from the parent's class. So what I want to achieve is:
trait Superclass {
def aFakeMethod: String = ""
val methods = myMacro[Self] // FIXME! self is not defined here...
}
class Hello extends Superclass {
def one(a: Int, b: UserId): String = a.toString + b.id
def two(c: Option[Int]): String = ""
def three(d: Seq[Int], f: Set[Int]): String = ""
}
val hi = new Hello
println(hi.methods) // Seq("one", "two", "three")
Because the high number of classes in the framework, modifying the api between Hello and Superclass is very expansive. So I would need a way to do this without changing code in Hello
Any suggestions on how this could be achieved?
If myMacro worked outside Hello it should work inside Superclass as well
import scala.language.experimental.macros
import scala.reflect.macros.blackbox
def myMacro[T]: Seq[String] = macro impl[T]
def impl[T: c.WeakTypeTag](c: blackbox.Context): c.Tree = {
import c.universe._
val methodNames = weakTypeOf[T].decls
.filter(symb => symb.isMethod && !symb.isConstructor)
.map(_.name.toString).toList
val methodNamesTree = methodNames.foldRight[Tree](q"Nil")((name, names) => q"$name :: $names")
q"..$methodNamesTree"
}
Usage:
sealed trait Superclass {
def aFakeMethod: String = ""
val methods = myMacro[Hello]
}
val hi = new Hello
println(hi.methods) // List("one", "two", "three")
If for some reason you can't use the name of Hello you can try to make Superclass sealed and use knownDirectSubclasses
def myMacro1(): Seq[String] = macro impl1
def impl1(c: blackbox.Context)(): c.Tree = {
import c.universe._
val child = c.enclosingClass.symbol.asClass.knownDirectSubclasses.head
q"myMacro[$child]"
}
Usage:
sealed trait Superclass {
def aFakeMethod: String = ""
val methods = myMacro1()
}
val hi = new Hello
println(hi.methods) // List("one", "two", "three")
Or you can replace deprecated c.enclosingClass.symbol.asClass with c.internal.enclosingOwner.owner.asClass (now enclosingOwner is val methods, enclosingOwner.owner is trait Superclass).
If you can't make Superclass sealed try to traverse all classes and look for those extending Superclass
def myMacro2(): Seq[Seq[String]] = macro impl2
def impl2(c: blackbox.Context)(): c.Tree = {
import c.universe._
def treeSymbol(tree: Tree): Symbol = c.typecheck(tree, mode = c.TYPEmode).symbol
val enclosingClassSymbol = c.internal.enclosingOwner.owner
def isEnclosingClass(tree: Tree): Boolean = treeSymbol(tree) == enclosingClassSymbol
var methodss = Seq[Seq[String]]()
val traverser = new Traverser {
override def traverse(tree: Tree): Unit = {
tree match {
case q"$_ class $_[..$_] $_(...$_) extends { ..$_ } with ..$parents { $_ => ..$stats }"
if parents.exists(isEnclosingClass(_)) =>
val methods = stats.collect {
case q"$_ def $tname[..$_](...$_): $_ = $_" => tname.toString
}
methodss :+= methods
case _ => ()
}
super.traverse(tree)
}
}
c.enclosingRun.units.foreach(unit => traverser.traverse(unit.body))
def namesToTree[A: Liftable](names: Seq[A]): Tree =
names.foldRight[Tree](q"Seq()")((name, names) => q"$name +: $names")
namesToTree[Tree](methodss.map(namesToTree[String](_)))
}
Usage:
trait Superclass {
def aFakeMethod: String = ""
val methods = myMacro2()
}
class Hello1 extends Superclass {
def four = ???
def five = ???
}
class Hello extends Superclass {
def one(a: Int, b: UserId): String = a.toString + b.id
def two(c: Option[Int]): String = ""
def three(d: Seq[Int], f: Set[Int]): String = ""
}
val hi = new Hello
println(hi.methods) // List(List("four", "five"), List("one", "two", "three"))

how to efficiently/cleanly override a copy method

I have a super and a subclass as follows:
class Animal(var x: Int) {
def greeting: String = "hi im an animal"
def copy: Animal = new Animal(x)
}
class Lion(override var x: Int) extends Animal(x){
override def greeting: String = "hi im a lion"
override def copy: Lion = new Lion(x)
}
I want both of them to have the exact same copy function (imagine it being larger than what I've given), except for the return type, I would like the Lion class to return a Lion when copy is invoked.
How can I cleanly override the Animal copy method without having code duplication?
In principle, methods apply/unapply, canEqual/equals/hashCode, toString, copy, productArity/productElement/productIterator/productPrefix can be generated with Shapeless case classes a la carte although I'm not sure whether this works with class hierarchies.
Anyway, you can generate apply with a macro annotation
import scala.annotation.{StaticAnnotation, compileTimeOnly}
import scala.language.experimental.macros
import scala.reflect.macros.blackbox
#compileTimeOnly("enable macro annotations")
class copy extends StaticAnnotation {
def macroTransform(annottees: Any*): Any = macro CopyMacro.impl
}
object CopyMacro {
def impl(c: blackbox.Context)(annottees: c.Tree*): c.Tree = {
import c.universe._
annottees match {
case q"$mods class $tpname[..$tparams] $ctorMods(...$paramss) extends { ..$earlydefns } with ..$parents { $self => ..$stats }" :: tail =>
val paramNamess = paramss.map(_.map {
case q"$_ val $tname: $_ = $_" => tname
case q"$_ var $tname: $_ = $_" => tname
})
val tparamNames = tparams.map {
case q"$_ type $tpname[..$_] = $_" => tpname
}
val doesOverrideCopy = parents.map {
case q"${parent#tq"$_[..$_]"}(...$_)" => parent
case parent#tq"$_[..$_]" => parent
}.exists(tree =>
c.typecheck(tree.duplicate, mode = c.TYPEmode)
.tpe
.member(TermName("copy")) != NoSymbol
)
val copyMod = if (doesOverrideCopy) Modifiers(Flag.OVERRIDE) else NoMods
q"""
$mods class $tpname[..$tparams] $ctorMods(...$paramss) extends { ..$earlydefns } with ..$parents { $self =>
..$stats
$copyMod def copy: $tpname[..$tparamNames] = new $tpname[..$tparamNames](...$paramNamess)
}
..$tail
"""
}
}
}
Usage:
#copy
class Animal(val x: Int) {
def greeting: String = "hi im an animal"
}
#copy
class Lion(override val x: Int) extends Animal(x) {
override def greeting: String = "hi im a lion"
}
//scalac: {
// class Animal extends scala.AnyRef {
// <paramaccessor> val x: Int = _;
// def <init>(x: Int) = {
// super.<init>();
// ()
// };
// def greeting: String = "hi im an animal";
// def copy: Animal = new Animal(x)
// };
// ()
//}
//scalac: {
// class Lion extends Animal(x) {
// override <paramaccessor> val x: Int = _;
// def <init>(x: Int) = {
// super.<init>();
// ()
// };
// override def greeting: String = "hi im a lion";
// override def copy: Lion = new Lion(x)
// };
// ()
//}
Alternatively, since class Animal(val x: Int) is case-class-like you can try to use shapeless.Generic
implicit class CopyOps[A](a: A)(implicit generic: Generic[A]) {
def copy: A = generic.from(generic.to(a))
}

Pass implicit parameter through multiple objects

I wonder is it possible to pass implicit params through singletons like that
case class Greet(g: String)
object Foo {
def greet(name: String)(implicit greet: Greet = Greet("Hello")) = println(greet.g + " " + name)
}
object Bar {
def greetBar = Foo.greet("Bar")
}
object Main {
def main(args: Array[String]): Unit = {
implicit val greet: Greet = Greet("Goodbye")
Foo.greet("Sunshine") // Goodbye Sunshine
Bar.greetBar // Hello Bar
}
}
Bar.greetBar doesn't affected by implicit value in main, but I want it to be affected without passing implicit param to greetBar, so is there any way to do something like that? Maybe there is a way to set an implicit for object but in outer of it?
You should add implicit parameter to the method
object Bar {
def greetBar(implicit greet: Greet /*= Greet("Hello")*/) = Foo.greet("Bar")
}
implicit val greet: Greet = Greet("Goodbye")
Bar.greetBar // Goodbye Bar
or make the object a class and add implicit parameter to the class
class Bar(implicit greet: Greet /*= Greet("Hello")*/) {
def greetBar = Foo.greet("Bar")
}
implicit val greet: Greet = Greet("Goodbye")
(new Bar).greetBar // Goodbye Bar
I commented out default value /*= Greet("Hello")*/. If you want greetBar not to compile when there is no implicit in scope then you should keep it commented out. If you want behavior similar to greet (i.e. Greet("Hello") when there is no implicit in scope) then you should uncomment it.
Please notice that you can avoid repeating default value if you define lower-priority implicit in companion object
case class Greet(g: String)
object Greet {
implicit val lowPriorityGreet: Greet = Greet("Hello")
}
object Foo {
def greet(name: String)(implicit greet: Greet) = println(greet.g + " " + name)
}
object Bar {
def greetBar(implicit greet: Greet) = Foo.greet("Bar")
}
// class Bar(implicit greet: Greet) {
// def greetBar = Foo.greet("Bar")
// }
implicit val greet: Greet = Greet("Goodbye")
Foo.greet("Sunshine") // Goodbye Sunshine
Bar.greetBar // Goodbye Bar
// (new Bar).greetBar // Goodbye Bar
See also
How to wrap a method having implicits with another method in Scala?
I want to do this to set Greet implict for all methods in Bar
In principle, you can do this with a macro annotation (but you shouldn't)
import scala.annotation.{StaticAnnotation, compileTimeOnly}
import scala.language.experimental.macros
import scala.reflect.macros.blackbox
#compileTimeOnly("enable macro annotations")
class greetAware extends StaticAnnotation {
def macroTransform(annottees: Any*): Any = macro GreetAwareMacro.impl
}
object GreetAwareMacro {
def impl(c: blackbox.Context)(annottees: c.Tree*): c.Tree = {
import c.universe._
val greet = TermName(c.freshName("greet"))
val implicitGreet = q"""implicit val $greet: Greet = Greet("Hello")"""
def isImplicit(param: Tree): Boolean = param match {
case q"$mods val $_: $_ = $_" => mods.hasFlag(Flag.IMPLICIT)
}
annottees match {
case q"$mods object $tname extends { ..$earlydefns } with ..$parents { $self => ..$body }" :: Nil =>
val body1 = body.map {
case q"$mods def $tname[..$tparams](...$paramss): $tpt = $expr" =>
val paramss1 =
if (paramss.nonEmpty && paramss.last.nonEmpty && isImplicit(paramss.last.head))
paramss.init :+ (paramss.last :+ implicitGreet)
else paramss :+ List(implicitGreet)
q"$mods def $tname[..$tparams](...$paramss1): $tpt = $expr"
case notMethod => notMethod
}
q"$mods object $tname extends { ..$earlydefns } with ..$parents { $self => ..$body1 }"
}
}
}
Usage:
#greetAware
object Foo {
def greet(name: String) = println(implicitly[Greet].g + " " + name)
}
#greetAware
object Bar {
def greetBar = Foo.greet("Bar")
def xxx(i: Int) = ???
def yyy(i: Int)(implicit s: String) = ???
}
implicit val greet: Greet = Greet("Goodbye")
Foo.greet("Sunshine") // Goodbye Sunshine
Bar.greetBar // Goodbye Bar
//scalac: object Foo extends scala.AnyRef {
// def <init>() = {
// super.<init>();
// ()
// };
// def greet(name: String)(implicit greet$macro$1: Greet = Greet("Hello")) = println(implicitly[Greet].g.$plus(" ").$plus(name))
//}
//scalac: object Bar extends scala.AnyRef {
// def <init>() = {
// super.<init>();
// ()
// };
// def greetBar(implicit greet$macro$2: Greet = Greet("Hello")) = Foo.greet("Bar");
// def xxx(i: Int)(implicit greet$macro$2: Greet = Greet("Hello")) = $qmark$qmark$qmark;
// def yyy(i: Int)(implicit s: String, greet$macro$2: Greet = Greet("Hello")) = $qmark$qmark$qmark
//}

Scala: constructor orders in inheritance

Can someone explain me in detail about orders in which constructors are called in inheritance in scala please? Say I have:
abstract class A {
private var data: T = compute()
protected def compute(): T
}
class ImpA extends A {
var a = 0
override def compute() {
a = 1
null.asInstanceOf[T] // doesn't matter
}
}
val inst = new ImpA
Then it appears that inst.a == 0, so I guess that what happens is that when ImpA's constructor is called then, A constructor is called also, which actually triggers compute() that should set a = 1. But then scala goes back down to ImpA's constructor and reset a = 0. Is that it?
Is there some well-known pattern to avoid this properly? (I'm not really trying to fix this problem that can be easily dealt with, though if there are patterns that are advised I'm eager to know them; but I'd rather like to have a deep understanding of what's happening, and hopefully know why reinitializing the variable a could be interested in that case. And also what would happen internally if it was a val as it would lead to assign several references to the same variables if the logic is kept...).
Thanks in advance.
EDIT: something fun also is when you just change ImpA.a and use a reference instead of a var:
class ImpA extends A {
class B {
var b = 0
}
val b = new B
override def compute() {
b.b += 1
null.asInstanceOf[T] // doesn't matter
}
}
then it throws a java.lang.NullPointerException because b isn't instantiated yet. Following Yuval Itzchakov solution, here's what it compiles into:
abstract class A extends Object {
private[this] var data: Object = _;
<accessor> private def data(): Object = A.this.data;
<accessor> private def data_=(x$1: Object): Unit = A.this.data = x$1;
protected def compute(): Object;
def <init>(): test.A = {
A.super.<init>();
A.this.data = A.this.compute();
()
}
};
class ImpA extends test.A {
private[this] val b: test.ImpA$B = _;
<stable> <accessor> def b(): test.ImpA$B = ImpA.this.b;
override def compute(): Unit = {
ImpA.this.b().b_=(ImpA.this.b().b().+(1));
{
(null: Object);
()
}
};
override <bridge> <artifact> def compute(): Object = {
ImpA.this.compute();
scala.runtime.BoxedUnit.UNIT
};
def <init>(): test.ImpA = {
ImpA.super.<init>();
ImpA.this.b = new test.ImpA$B(ImpA.this);
()
}
};
class ImpA$B extends Object {
private[this] var b: Int = _;
<accessor> def b(): Int = ImpA$B.this.b;
<accessor> def b_=(x$1: Int): Unit = ImpA$B.this.b = x$1;
<synthetic> <paramaccessor> <artifact> protected val $outer: test.ImpA = _;
<synthetic> <stable> <artifact> def $outer(): test.ImpA = ImpA$B.this.$outer;
def <init>($outer: test.ImpA): test.ImpA$B = {
if ($outer.eq(null))
throw null
else
ImpA$B.this.$outer = $outer;
ImpA$B.super.<init>();
ImpA$B.this.b = 0;
()
}
}
Though it's a bit harder to understand properly, it explains quite straightforwardly why the NullPointerException is thrown.
But if you use this time a lazy val b = new B, then it works:
class ImpA extends test.A {
#volatile private[this] var bitmap$0: Boolean = false;
private def b$lzycompute(): test.ImpA$B = {
{
ImpA.this.synchronized({
if (ImpA.this.bitmap$0.unary_!())
{
ImpA.this.b = new test.ImpA$B(ImpA.this);
ImpA.this.bitmap$0 = true;
()
};
scala.runtime.BoxedUnit.UNIT
});
()
};
ImpA.this.b
};
lazy private[this] var b: test.ImpA$B = _;
<stable> <accessor> lazy def b(): test.ImpA$B = if (ImpA.this.bitmap$0.unary_!())
ImpA.this.b$lzycompute()
else
ImpA.this.b;
override def compute(): Unit = {
ImpA.this.b().b_=(ImpA.this.b().b().+(1));
{
(null: Object);
()
}
};
override <bridge> <artifact> def compute(): Object = {
ImpA.this.compute();
scala.runtime.BoxedUnit.UNIT
};
def <init>(): test.ImpA = {
ImpA.super.<init>();
()
}
};
Let's see what the compiler generates when compiling (using the -Xprint:jvm flag):
class ImpA extends com.testing.A {
private[this] var a: Int = _;
<accessor> def a(): Int = ImpA.this.a;
<accessor> def a_=(x$1: Int): Unit = ImpA.this.a = x$1;
override def compute(): String = {
ImpA.this.a_=(1);
(null: String)
};
override <bridge> <artifact> def compute(): Object = ImpA.this.compute();
def <init>(): com.testing.ImpA = {
ImpA.super.<init>();
ImpA.this.a = 0;
()
}
};
What do we see? We see that the constructor running for ImplA (defined as the <init> method) first calls ImpA.super.<init>(), which is a call to A to initialize itself first. As initialization code looks like this:
def <init>(): com.testing.A = {
A.super.<init>();
A.this.data = A.this.compute();
()
}
It calls A.super, which is Object, and then calls A.this.compute(). This method initializes a to hold the value 1. Once that initialization finishes, ImplA sets a to 0, as you told it to do during constructor initialization. That is why you're seeing the value 0 for a.
To sum up, the execution flow is as follows:
ImplA calls As init method
A calls compute, which is invoked on ImplA
ImplA.compute assigns a the value 1
ImplA assigns a the value 0
For more, see http://docs.scala-lang.org/tutorials/FAQ/initialization-order.html

Scala compiler says my method is recursive in case when implicits and anonymous class is used

I want to be able to write code like
10 times {
doSomething
}
So I thought I could do that with implicits.
When i execute the following code in the Scala REPL it gets defined correctly
scala> implicit def intToMyRichInt(count: Int) = {
| new {
| def times(f: => Unit) = {
| 1 to count foreach { _ => f }
| }
| }
| }
However when i try to compile,
object Test {
implicit def intToMyRichInt(count: Int) = {
new {
def times(f: => Unit) = {
1 to count foreach { _ => f }
}
}
}
it fails with the error
error: recursive method intToMyRichInt needs result type
1 to count foreach { _ => f }
What is the difference? What am I doing wrong?
After fix the code by removing the def's {, it compiled just fine:
scala> object Test {
| implicit def intToMyRichInt(count: Int) = {
| new {
| def times(f: => Unit) =
| 1 to count foreach { _ => f }
| }
| }
| }
defined module Test
It's also recommended to remove the {} after the implicit def:
object Test {
implicit def intToMyRichInt(count: Int) =
new {
def times(f: => Unit) =
1 to count foreach { _ => f }
}
}
Also, it's worth mentioning the new { ... class content ... } is actually a structural type to compiler, so invocations to times will be made reflectively. One work-around is to create a new class:
object Test {
class MyRichInt(x:Int) {
def times(f: => Unit) = 1 to x foreach { _ => f }
}
implicit def intToMyRichInt(count: Int) = new MyRichInt(count)
}
Hope to have answered your question.
#tbruhn: I could not verify your problem, it compiles fine here.
I suspect that you are using some outdated version of Scala maybe?
If that's the case, the obvious fix is upgrading to Scala 2.8.x!
Otherwise, how do you compile? If you are compiling via your IDE, try to see if scalac has the same error.
I think scala won't be able to infer return types for recursive functions for reasons that I once knew but now forget.
But in your case I can compile the file successfully except it misses one more }.
Unfortunately, workaround suggested by pedrofurla doesn't appear to work (at least in 2.8.0 final):
object Test {
implicit def intToMyRichInt(count: Int) =
new ScalaObject {
def times(f: => Unit) =
1 to count foreach { _ => f }
}
def foo = 10.times { println("foo") }
}
F:\MyProgramming\raw>scalac -Xprint:jvm Main.scala
[[syntax trees at end of jvm]]// Scala source: Main.scala
package <empty> {
final class Test extends java.lang.Object with ScalaObject {
final private <synthetic> <static> var reflParams$Cache1: Array[java.lang.Class] = Array[java.lang.Class]{classOf[scala.Function0]};
#volatile private <synthetic> <static> var reflPoly$Cache1: java.lang.ref.SoftReference = new java.lang.ref.SoftReference(new scala.runtime.EmptyMethodCache());
<synthetic> <static> def reflMethod$Method1(x$1: java.lang.Class): java.lang.reflect.Method = {
if (Test.reflPoly$Cache1.get().$asInstanceOf[scala.runtime.MethodCache]().eq(null))
Test.reflPoly$Cache1 = new java.lang.ref.SoftReference(new scala.runtime.EmptyMethodCache());
var method1: java.lang.reflect.Method = Test.reflPoly$Cache1.get().$asInstanceOf[scala.runtime.MethodCache]().find(x$1);
if (method1.ne(null))
return method1
else
{
method1 = x$1.getMethod("times", Test.reflParams$Cache1);
Test.reflPoly$Cache1 = new java.lang.ref.SoftReference(Test.reflPoly$Cache1.get().$asInstanceOf[scala.runtime.MethodCache]().add(x$1, method1));
return method1
}
};
implicit def intToMyRichInt(count$1: Int): ScalaObject = new Test$$anon$1(count$1);
def foo(): Unit = {
{
val qual1: ScalaObject = Test.this.intToMyRichInt(10);
{
{
var exceptionResult1: java.lang.Object = _;
try {
exceptionResult1 = Test.reflMethod$Method1(qual1.getClass()).invoke(qual1, Array[java.lang.Object]{{
(new Test$$anonfun$foo$1(): Function0)
}})
} catch {
case ($1$ # (_: java.lang.reflect.InvocationTargetException)) => {
exceptionResult1 = throw $1$.getCause()
}
};
exceptionResult1
};
scala.runtime.BoxedUnit.UNIT
}
};
()
};
def this(): object Test = {
Test.reflParams$Cache1 = Array[java.lang.Class]{classOf[scala.Function0]};
Test.reflPoly$Cache1 = new java.lang.ref.SoftReference(new scala.runtime.EmptyMethodCache());
Test.super.this();
()
}
};
#SerialVersionUID(0) #serializable final <synthetic> class Test$$anon$1$$anonfun*$1 extends scala.runtime.AbstractFunction1$mcVI$sp {
final def apply(x$1: Int): Unit = Test$$anon$1$$anonfun*$1.this.apply$mcVI$sp(x$1);
<specialized> def apply$mcVI$sp(v1: Int): Unit = Test$$anon$1$$anonfun*$1.this.f$1.apply$mcV$sp();
final <bridge> def apply(v1: java.lang.Object): java.lang.Object = {
Test$$anon$1$$anonfun*$1.this.apply(scala.Int.unbox(v1));
scala.runtime.BoxedUnit.UNIT
};
<synthetic> <paramaccessor> private[this] val f$1: Function0 = _;
def this($outer: Test$$anon$1, f$1: Function0): Test$$anon$1$$anonfun*$1 = {
Test$$anon$1$$anonfun*$1.this.f$1 = f$1;
Test$$anon$1$$anonfun*$1.super.this();
()
}
};
final class Test$$anon$1 extends java.lang.Object with ScalaObject {
def times(f$1: Function0): Unit = scala.this.Predef.intWrapper(1).to(Test$$anon$1.this.count$1).$asInstanceOf[scala.collection.immutable.Range$ByOne]().foreach$mVc$sp({
(new Test$$anon$1$$anonfun*$1(Test$$anon$1.this, f$1): Function1)
});
<synthetic> <paramaccessor> private[this] val count$1: Int = _;
def this(count$1: Int): Test$$anon$1 = {
Test$$anon$1.this.count$1 = count$1;
Test$$anon$1.super.this();
()
}
};
#SerialVersionUID(0) #serializable final <synthetic> class Test$$anonfun$foo$1 extends scala.runtime.AbstractFunction0$mcV$sp {
final def apply(): Unit = Test$$anonfun$foo$1.this.apply$mcV$sp();
<specialized> def apply$mcV$sp(): Unit = scala.this.Predef.println("foo");
final <bridge> def apply(): java.lang.Object = {
Test$$anonfun$foo$1.this.apply();
scala.runtime.BoxedUnit.UNIT
};
def this(): Test$$anonfun$foo$1 = {
Test$$anonfun$foo$1.super.this();
()
}
}
}