aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* fix procedure syntaxxuwei-k2018-05-0932-172/+172
|
* drop support for Scala 2.11 as of 0.10.0Seth Tisue2018-05-012-34/+9
| | | | also upgrade Scala 2.12.4 -> 2.12.6
* fixes for 2.13 compatibilitySeth Tisue2018-03-141-3/+3
| | | | as discovered by the Scala 2.13 community build
* Remove use of scala.concurrent.forkjoinNthPortal2018-03-141-1/+1
| | | | | Remove use of scala.concurrent.forkjoin. Remove support for JDK 6.
* locate the classes directory reliablySeth Tisue2018-03-051-17/+9
| | | | | | | | | | the old code would fail with e.g. > ++2.12.5-bin-76f588e-SNAPSHOT > testOnly *WarningsSpec this was showing up repeatedly when running the Scala community build against as-yet-unmerged scala/scala PRs
* Remove uses of deprecated Future APIsNthPortal2018-02-2713-57/+66
|
* copyright 2018 LightbendSeth Tisue2018-02-0636-37/+37
|
* fix Scala version number handling for 2.13 community buildSeth Tisue2018-01-231-1/+1
| | | | | we need to handle a Scala version like `2.13.0-pre-5e84129`, as we see in nightly builds before bincompat is locked down
* Avoid NPE with import treesJason Zaugg2017-11-271-1/+1
|
* Workaround ill-scoped exist. skolem refs emited by patmatJason Zaugg2017-10-162-1/+41
| | | | | | | | | | | | | | | | | | | e.g `val x2 = Foo[$1] with Bar = boundValue` is rewritten to `val x2 = (Foo[$1] @uncheckedBounds) with Bar = boundValue` This is to have refchecks turn a blind eye to the type argument that doesn't conform the to type parameter bounds. For regular compilation, without the async transform between patmat and refchecks, bound conformance is disabled with: https://github.com/scala/scala/blob/v2.11.7/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala#L1743 Using the `uncheckedBounds` annotation is a newer, more inclusive way of acheiving the same thing: https://github.com/scala/scala/blob/v2.11.7/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala#L1677
* Add missing recursion to branchWithAssignJason Zaugg2017-10-161-1/+1
|
* Merge pull request #178 from retronym/tyconJason Zaugg2017-10-132-25/+39
|\ | | | | Fix decision about whether to use a trait or class as the parent
| * Fix race condition in tests and make some tests actually runJason Zaugg2017-10-131-28/+37
| |
| * Add diagnostic for intermittently failing testJason Zaugg2017-10-131-1/+6
| |
| * Fix decision about whether to use a trait or class as the parentJason Zaugg2017-10-131-1/+1
| |
* | Fix ANF transform for corner case in late transformsJason Zaugg2017-09-293-17/+42
|/ | | | | Unfortunately I wasn't able to extract a test case, but the patch has been tested to fix a problem on a real world code base.
* Eliminate dead statesJason Zaugg2017-09-271-2/+63
| | | | | | | | | | | | | If a state does nothing but unconditionally transition to the next state, remove it and rewrite predecessors to directly jump to the successor state (or to the first non-dead successor.) While we're doing this, compact the remaining state IDs to be contiguous, which will allow use of a tableswitch in bytecode. Sample bytecode demonstrating a tableswitch: https://gist.github.com/retronym/6880c35b501fc1c91bed7f30c0f2c045
* Allow result field name to be externally specifiedJason Zaugg2017-09-272-2/+3
|
* Support future systems that perform external failure handlingJason Zaugg2017-09-273-11/+20
|
* Allow future system to enable more name fresheningJason Zaugg2017-09-272-13/+32
|
* Reduce logging overhead and minor cleanupsRory Graves2017-06-2114-46/+53
|
* In tests use tmp dir working on all operating systemsMichał Pociecha2016-11-221-1/+1
| | | | After this change tests pass also on Windows.
* Merge pull request #160 from retronym/topic/2.12Jason Zaugg2016-09-086-10/+23
|\ | | | | Compatibility with Scala 2.12.0-RC1
| * Compatibility with Scala 2.12.0-RC1Jason Zaugg2016-09-086-10/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.
* | Rework extension point for checking for already-completed futuresJason Zaugg2016-03-033-12/+15
|/ | | | | | | | | | | | The current extension point assumes that if a future is in the completed state, a subsequent call to get the already completed value will succeed. While this assumption holds for scala.concurrent.Future, it might not hold for a future system that has semantics like a weak reference. This commit uses a single call `getCompleted` to query the state and get the already completed value. This returns null if the value is not available.
* Various fixes to late expansionJason Zaugg2016-01-197-78/+481
| | | | | | | | | | | | | | | | | | - 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.
* Use AbstractFunction as a base class to emit leaner codeJason Zaugg2016-01-191-1/+9
| | | | | | | | | Avoids mixing in all the specialized apply variants. We could go further and create an base class for all state machines, but that would require scala-async to be on the runtime classpath, which currently isn't a requirement. For now, I'm keeping it this way.
* Hooks to customize code generationJason Zaugg2015-11-103-3/+5
|
* Avoid spurious "illegal await" error in IDE with nestingJason Zaugg2015-10-097-17/+63
| | | | | | | | | | | | | | | | | | | The presentation compiler runs with `-Ymacro-expand:discard`, which retains the macro expandee in the typechecked trees, rather than substituting in the expansion. This mode was motivated as a means to keep IDE functionality working (e.g. completion, navigation, refactoring) inside macro applications. However, if one has nested async macro applications, as reported in the IDE ticket: https://www.assembla.com/spaces/scala-ide/tickets/1002561 ... the expansion of the outer async application was reporting await calls enclosed by the inner async application. This change tweaks the traversers used for this analysis to stop whenever it sees an async.
* Small cleanups after code reviewJason Zaugg2015-09-233-12/+40
| | | | | | | | - More internal docs - Be more frugal with the `NoAwait` attachment, for some AST node types this is implied. - Just use `x`, rather than what was effectively `x.reverseMap(identity).reverse`
* Enable a compiler plugin to use the async transform after patmatJason Zaugg2015-09-2211-54/+430
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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} ```
* TypoBruno Bieth2015-08-181-1/+1
|
* Make nsc.Global based tests work under SBTJason Zaugg2015-07-301-17/+3
| | | | And remove unused code.
* Stop test compiler before code generationJason Zaugg2015-07-301-3/+3
| | | | | This avoids leaving .class files in the working directory after running the test.
* Avoid dead code warning with async(throw T)Jason Zaugg2015-07-293-2/+21
| | | | | | By declararing the parameter of `async` as by-name. Fixes #150 (the bug in the original ticket.)
* Avoid dead code warnings in generated code.Jason Zaugg2015-07-293-4/+58
| | | | | | | | | | | | | | | | | If we blindly splicing `{..$stats, ..$generatedCode}`, and the last expression in `$stats` is of type `Nothing`, we'll incur a dead code warning when typechecking the block. This commit: - introduces a helper method to augment user-written stats with synthetic code - Emit a try/finally in that code (so we advance the state, even if we are about to exit the state machine in the async-block global exception handler - Hide `Nothing` typed expressions from the dead code analysis by wrapping them in an `expr: Any` Fixes #150 (the part reported in the comments, not the original ticket.)
* Cleanup code generation by avoiding redundant blocksJason Zaugg2015-07-292-19/+44
| | | | | | | Don't bother adding `{ ...; () }` if we can use the original tree(s) instead, e.g. if the last tree in `...` conforms to `Unit`. This makes the debug output of the macro a little easier to read.
* Merge pull request #122 from retronym/ticket/120v0.9.5_2.11Jason Zaugg2015-07-273-2/+50
|\ | | | | Avoid masking user exception with ??? for Nothing typed expressions
| * Avoid masking user exception with ??? for Nothing typed expressionsJason Zaugg2015-07-273-2/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code like: val x = if (cond) throw new A else throw new B Was being transformed to: val ifRes = ??? if (cond) ifRes = throw new A else ifRes = throw new B val x = ifRes by way of the use of `gen.mkZero` which throws `???` if the requested type is `Nothing` This commit special cases `Nothing` typed expressions in a similar manner to `Unit` type expressions. The example above is now translated to: if (cond) throw new A else throw new B val x = throw new IllegalStateException() Fixes #120
* | Avoid leaking untyped trees out of macroJason Zaugg2015-07-271-1/+1
|/ | | | | | | | | | The stack trace and bisection in #119 made me notice that we are failing to typecheck the cast we generated in the fix for #74. The ticket doesn't have a reproduction, so I'm submitting this without a test case. Fixes #119
* Avoid compiler warning when awaiting Future[Unit]Jason Zaugg2015-07-072-1/+46
| | | | | | | | | | | | | | | | | | | | | | During the ANF transform, we were generating a tree of the shape: { val temp: Unit = await(futureOfUnit) temp () } I tried to simplifiy this to avoid creating the temporary value, but this proved difficult as it would have required changes to the subsequent state machine transformation. Even replacing `temp` with `()` made the state machine transform harder. So for now, I've just inserted `temp.asInstanceOf[Unit]` to hide from the compiler warning. Fixes #74
* Avoid masking real errors with NotImplemented awaiting Future[Nothing]Jason Zaugg2015-07-062-1/+27
| | | | | | This commit disabled live variable analysis for intermediate values of type Nothing. Fixes #104
* Fix compiler crash with value class in result positionJason Zaugg2015-07-062-2/+14
| | | | | | | We were leaking untyped trees out of the macro, which crashed in refchecks. This commit proactively typechecks the tree returned by `mkZero`.
* Merge remote-tracking branch 'origin/2.10.x' into ↵Jason Zaugg2014-12-189-88/+166
|\ | | | | | | | | | | | | | | | | merge/2.10.x-to-master-20141219 Conflicts: src/main/scala/scala/async/internal/AsyncTransform.scala src/main/scala/scala/async/internal/ExprBuilder.scala src/test/scala/scala/async/TreeInterrogation.scala
| * Make `f(await(completedFuture))` execute `f` synchronouslyJason Zaugg2014-12-164-35/+85
| | | | | | | | | | | | A worthy optimization, suggested by @danarmak. Closes #73
| * Remove extraneous method in generated code.Jason Zaugg2014-12-151-7/+2
| |
| * Avoid unbounded stack consumption for synchronous control flowJason Zaugg2014-12-157-54/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, as sequence of state transitions that did not pass through an asynchrous boundary incurred stack frames. The trivial loop in the enclosed test case would then overflow the stack. This commit merges the `resume` and `apply(tr: Try[Any])` methods into a `apply`. It changes the body of this method to be an infinite loop with returns at the terminal points in the state machine (or at a terminal failure.) To allow merging of these previously separate matches, states that contain an await are now allocated two state ids: one for the setup code that calls `onComplete`, and one for the code in the continuation that records the result and advances the state machine. Fixes #93
* | Fix regression around await of non-class typeGene Novark2014-12-092-4/+20
| | | | | | | | E.g. type param, abstrat type.
* | Additional tests and comments around mkZero for value classesJason Zaugg2014-10-012-1/+35
| |
* | Merge branch 'ticket/86-mkZero' into merge/2.10.x-to-master-20140930Jason Zaugg2014-10-014-9/+73
|\| | | | | | | | | | | | | Conflicts: src/main/scala/scala/async/internal/AnfTransform.scala src/main/scala/scala/async/internal/AsyncTransform.scala src/test/scala/scala/async/run/toughtype/ToughType.scala