Skip to content

Instantly share code, notes, and snippets.

@retronym retronym/0.code.scala

Last active Mar 16, 2020
Embed
What would you like to do?
import scala.concurrent._, duration.Duration, ExecutionContext.Implicits.global
import scala.async.Async.{async, await}
object Test {
def test: Future[Int] = async { await(f(1)) + await(f(2)) }
def f(x: Int): Future[Int] = Future.successful(x)
}
<method> def apply(tr$async: util.this.Try): scala.this.Unit = while$(){
try {
Test$stateMachine$async$1.this.state$async() match {
case 0 => {
val awaitable$async: concurrent.this.Future = Test.this.f(1);
tr$async = if (awaitable$async.isCompleted())
awaitable$async.value().get().$asInstanceOf[util.this.Try]()
else
null;
Test$stateMachine$async$1.this.state$async_$eq(1);
if (null.ne(tr$async))
while$()
else
{
awaitable$async.onComplete(this, Test$stateMachine$async$1.this.execContext$async());
return ()
}
}
case 1 => {
Test$stateMachine$async$1.this.await$async$0 = null;
if (tr$async.isFailure())
{
Test$stateMachine$async$1.this.result$async().complete(tr$async);
return ()
}
else
Test$stateMachine$async$1.this.await$async$0 = tr$async.get();
val awaitable$async: concurrent.this.Future = Test.this.f(2);
tr$async = if (awaitable$async.isCompleted())
awaitable$async.value().get().$asInstanceOf[util.this.Try]()
else
null;
Test$stateMachine$async$1.this.state$async_$eq(2);
if (null.ne(tr$async))
while$()
else
{
awaitable$async.onComplete(this, Test$stateMachine$async$1.this.execContext$async());
return ()
}
}
case 2 => {
<mutable> <synthetic> var await$async$1: lang.this.Object = null;
if (tr$async.isFailure())
{
Test$stateMachine$async$1.this.result$async().complete(tr$async);
return ()
}
else
await$async$1 = tr$async.get();
<synthetic> val x$async$1: scala.this.Int = scala.Int.unbox(await$async$1);
Test$stateMachine$async$1.this.result$async().complete(new util.Success.<init>(scala.Int.box(scala.Int.unbox(Test$stateMachine$async$1.this.await$async$0).$plus(x$async$1))));
return ();
Test$stateMachine$async$1.this.await$async$0 = null
}
case _ => throw new IllegalStateException.<init>(java.lang.String.valueOf(Test$stateMachine$async$1.this.state$async()))
}
} catch {
case (throwable$async @ (_: Throwable)) => {
Test$stateMachine$async$1.this.result$async().complete(new util.Failure.<init>(throwable$async));
return ()
}
};
while$()
};
<method> def apply(tr$async: util.this.Try): scala.this.Unit = while$(){
try {
if (null.ne(tr$async))
if (tr$async.isFailure())
{
Test$stateMachine$async$1.this.result$async().complete(tr$async);
return ()
}
else
()
else
();
Test$stateMachine$async$1.this.state$async() match {
case 0 => {
val awaitable$async: concurrent.this.Future = Test.this.f(1);
await(awaitable$async, 1)
}
case 1 => {
Test$stateMachine$async$1.this.await$async$0 = tr$async.get();
val awaitable$async: concurrent.this.Future = Test.this.f(2);
await(awaitable$async, 2)
}
case 2 => {
<synthetic> val await$async$1: lang.this.Object = tr$async.get();
<synthetic> val x$async$1: scala.this.Int = scala.Int.unbox(await$async$1);
Test$stateMachine$async$1.this.result$async().complete(new util.Success.<init>(scala.Int.box(scala.Int.unbox(Test$stateMachine$async$1.this.await$async$0).$plus(x$async$1))));
return ()
}
case _ => throw new IllegalStateException.<init>(java.lang.String.valueOf(Test$stateMachine$async$1.this.state$async()))
}
} catch {
case (throwable$async @ (_: Throwable)) => {
Test$stateMachine$async$1.this.result$async().complete(new util.Failure.<init>(throwable$async));
return ()
}
};
while$();
await(x: concurrent.this.Future, state: scala.this.Int){
tr$async = if (x.isCompleted())
x.value().get().$asInstanceOf[util.this.Try]()
else
null;
Test$stateMachine$async$1.this.state$async_$eq(state);
if (null.ne(tr$async))
while$()
else
{
x.onComplete(this, Test$stateMachine$async$1.this.execContext$async());
return ()
}
}
};
@@ -1,65 +1,52 @@
<method> def apply(tr$async: util.this.Try): scala.this.Unit = while$(){
try {
+ if (null.ne(tr$async))
+ if (tr$async.isFailure())
+ {
+ Test$stateMachine$async$1.this.result$async().complete(tr$async);
+ return ()
+ }
+ else
+ ()
+ else
+ ();
Test$stateMachine$async$1.this.state$async() match {
case 0 => {
val awaitable$async: concurrent.this.Future = Test.this.f(1);
- tr$async = if (awaitable$async.isCompleted())
- awaitable$async.value().get().$asInstanceOf[util.this.Try]()
- else
- null;
- Test$stateMachine$async$1.this.state$async_$eq(1);
- if (null.ne(tr$async))
- while$()
- else
- {
- awaitable$async.onComplete(this, Test$stateMachine$async$1.this.execContext$async());
- return ()
- }
+ await(awaitable$async, 1)
}
case 1 => {
- Test$stateMachine$async$1.this.await$async$0 = null;
- if (tr$async.isFailure())
- {
- Test$stateMachine$async$1.this.result$async().complete(tr$async);
- return ()
- }
- else
- Test$stateMachine$async$1.this.await$async$0 = tr$async.get();
+ Test$stateMachine$async$1.this.await$async$0 = tr$async.get();
val awaitable$async: concurrent.this.Future = Test.this.f(2);
- tr$async = if (awaitable$async.isCompleted())
- awaitable$async.value().get().$asInstanceOf[util.this.Try]()
- else
- null;
- Test$stateMachine$async$1.this.state$async_$eq(2);
- if (null.ne(tr$async))
- while$()
- else
- {
- awaitable$async.onComplete(this, Test$stateMachine$async$1.this.execContext$async());
- return ()
- }
+ await(awaitable$async, 2)
}
case 2 => {
- <mutable> <synthetic> var await$async$1: lang.this.Object = null;
- if (tr$async.isFailure())
- {
- Test$stateMachine$async$1.this.result$async().complete(tr$async);
- return ()
- }
- else
- await$async$1 = tr$async.get();
+ <synthetic> val await$async$1: lang.this.Object = tr$async.get();
<synthetic> val x$async$1: scala.this.Int = scala.Int.unbox(await$async$1);
Test$stateMachine$async$1.this.result$async().complete(new util.Success.<init>(scala.Int.box(scala.Int.unbox(Test$stateMachine$async$1.this.await$async$0).$plus(x$async$1))));
- return ();
- Test$stateMachine$async$1.this.await$async$0 = null
+ return ()
}
case _ => throw new IllegalStateException.<init>(java.lang.String.valueOf(Test$stateMachine$async$1.this.state$async()))
}
} catch {
case (throwable$async @ (_: Throwable)) => {
Test$stateMachine$async$1.this.result$async().complete(new util.Failure.<init>(throwable$async));
return ()
}
};
- while$()
- };
+ while$();
+ await(x: concurrent.this.Future, state: scala.this.Int){
+ tr$async = if (x.isCompleted())
+ x.value().get().$asInstanceOf[util.this.Try]()
+ else
+ null;
+ Test$stateMachine$async$1.this.state$async_$eq(state);
+ if (null.ne(tr$async))
+ while$()
+ else
+ {
+ x.onComplete(this, Test$stateMachine$async$1.this.execContext$async());
+ return ()
+ }
+ }
+ };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.