aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/scala/async/internal/Lifter.scala
Commit message (Collapse)AuthorAgeFilesLines
* Compatibility with Scala 2.12.0-RC1Jason Zaugg2016-09-081-2/+3
| | | | | | | | | | | | | | | | - method local lazy vals are now encoded as a single ValDef rather than a ValDef + DefDef pair. We need to treat ValDef-s with the LAZY flag in the same way as we used to treat the DefDef. - Rename one of the symbols `ANF,anf` in the same scope to avoid generating anonymous class names that differ only in case. The compiler warned about this one. - When patching the LabelDefs to have a `Unit` result type, propagate this other LabelDefs conclude with a jump to that label. Not sure why, but without this we now hit an error in the backend about the nonsensical attempt to emit a coercion from void to int. - Use crossScalaVersions in the build and update the Scala versions tested in CI.
* Various fixes to late expansionJason Zaugg2016-01-191-2/+3
| | | | | | | | | | | | | | | | | | - Detect cross-state symbol references where the RefTree is nested in a LabelDef. Failure to do so led to ill-scoped local variable references which sometimes manifest as VerifyErrors. - Emit a default case in the Match intended to be a tableswitch. We have to do this ourselves if we expand after pattern matcher - Cleanup generated code to avoid redundant blocks - Avoid unnecessary `matchRes` temporary variable for unit-typed pattern matches - Fix the trace level logging in the ANF transform to restore indented output. - Emit `{ state = nextState; ... }` rather than `try { ... } finally { state = nextState }` in state handlers. This simplifies generated code and has the same meaning, as the code in the state machine isn't reentrant and can't observe the "early" transition of the state.
* Enable a compiler plugin to use the async transform after patmatJason Zaugg2015-09-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the async transformation is performed during the typer phase, like all other macros. We have to levy a few artificial restrictions on whern an async boundary may be: for instance we don't support await within a pattern guard. A more natural home for the transform would be after patterns have been translated. The test case in this commit shows how to use the async transform from a custom compiler phase after patmat. The remainder of the commit updates the implementation to handle the new tree shapes. For states that correspond to a label definition, we use `-symbol.id` as the state ID. This made it easier to emit the forward jumps to when processing the label application before we had seen the label definition. I've also made the transformation more efficient in the way it checks whether a given tree encloses an `await` call: we traverse the input tree at the start of the macro, and decorate it with tree attachments containig the answer to this question. Even after the ANF and state machine transforms introduce new layers of synthetic trees, the `containsAwait` code need only traverse shallowly through those trees to find a child that has the cached answer from the original traversal. I had to special case the ANF transform for expressions that always lead to a label jump: we avoids trying to push an assignment to a result variable into `if (cond) jump1() else jump2()`, in trees of the form: ``` % cat sandbox/jump.scala class Test { def test = { (null: Any) match { case _: String => "" case _ => "" } } } % qscalac -Xprint:patmat -Xprint-types sandbox/jump.scala def test: String = { case <synthetic> val x1: Any = (null{Null(null)}: Any){Any}; case5(){ if (x1.isInstanceOf{[T0]=> Boolean}[String]{Boolean}) matchEnd4{(x: String)String}(""{String("")}){String} else case6{()String}(){String}{String} }{String}; case6(){ matchEnd4{(x: String)String}(""{String("")}){String} }{String}; matchEnd4(x: String){ x{String} }{String} }{String} ```
* Merge remote-tracking branch 'origin/2.10.x' into ↵Jason Zaugg2014-07-211-2/+1
|\ | | | | | | | | | | | | | | merge/2.10.x-to-master-20140721 Conflicts: src/main/scala/scala/async/internal/AsyncTransform.scala src/main/scala/scala/async/internal/Lifter.scala
| * Avoid NotImplementedError awaiting a Future[Nothing]Jason Zaugg2014-06-141-2/+1
| | | | | | | | | | | | | | `gen.mkZero(NothingTpe)` gives the tree `Predef.???`. Instead, we should leave the `await` field uninitialized with `ValDef(..., rhs = EmptyTree)`. Fixes #66
* | AsyncMacro.global is goneEugene Burmako2014-02-151-11/+13
| |
* | cleans up LifterEugene Burmako2014-02-151-2/+2
|/
* Clean-ups found during review of PR #43Philipp Haller2013-11-141-10/+2
|
* Fix crasher in icode due to symbol mismatches in lifted methodsJason Zaugg2013-11-141-37/+44
| | | | | | | | | These stem from the handling of the internal/external view or method type parameters by `thisMethodType` in `Namers`. I've now preseversed the orginal ValDefs favoured the latter when constructing the new DefDef, and made construction of all liftables consistent in this regard.
* Move implementation details to scala.async.internal._.Jason Zaugg2013-07-071-0/+150
If we intend to keep CPS fallback around for any length of time it should probably move there too.