diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-01-19 14:35:32 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-01-19 14:35:32 +1000 |
commit | 4395afe0ab7c59f088607d0849abe48b0f83265d (patch) | |
tree | 7a7c778a24143923a674acb9db30ecdc5e3f8f5e /src/main/scala/scala/async/internal/AsyncTransform.scala | |
parent | 656748c2c3c094c19d28a59c466d67437b7d6f6c (diff) | |
parent | 549a656fa22af5f7f0c5e89dd6e0a19ed4b604f5 (diff) | |
download | scala-async-4395afe0ab7c59f088607d0849abe48b0f83265d.tar.gz scala-async-4395afe0ab7c59f088607d0849abe48b0f83265d.tar.bz2 scala-async-4395afe0ab7c59f088607d0849abe48b0f83265d.zip |
Merge pull request #151 from retronym/topic/late-expansion-fixesv0.9.6-RC3
Late expansion fixes
Diffstat (limited to 'src/main/scala/scala/async/internal/AsyncTransform.scala')
-rw-r--r-- | src/main/scala/scala/async/internal/AsyncTransform.scala | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main/scala/scala/async/internal/AsyncTransform.scala b/src/main/scala/scala/async/internal/AsyncTransform.scala index 2e8dcf9..2f45034 100644 --- a/src/main/scala/scala/async/internal/AsyncTransform.scala +++ b/src/main/scala/scala/async/internal/AsyncTransform.scala @@ -49,8 +49,16 @@ trait AsyncTransform { List(emptyConstructor, stateVar) ++ resultAndAccessors ++ List(execContextValDef) ++ List(applyDefDefDummyBody, apply0DefDef) } - val tryToUnit = appliedType(definitions.FunctionClass(1), futureSystemOps.tryType[Any], typeOf[Unit]) - val template = Template(List(tryToUnit, typeOf[() => Unit]).map(TypeTree(_)), emptyValDef, body) + val customParents = futureSystemOps.stateMachineClassParents + val tycon = if (customParents.exists(!_.typeSymbol.asClass.isTrait)) { + // prefer extending a class to reduce the class file size of the state machine. + symbolOf[scala.runtime.AbstractFunction1[Any, Any]] + } else { + // ... unless a custom future system already extends some class + symbolOf[scala.Function1[Any, Any]] + } + val tryToUnit = appliedType(tycon, futureSystemOps.tryType[Any], typeOf[Unit]) + val template = Template((futureSystemOps.stateMachineClassParents ::: List(tryToUnit, typeOf[() => Unit])).map(TypeTree(_)), emptyValDef, body) val t = ClassDef(NoMods, name.stateMachineT, Nil, template) typecheckClassDef(t) |