aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #141 from retronym/ticket/await-extractorv0.9.6-RC1_2.11v0.9.5-RC1_2.11Jason Zaugg2015-09-2411-55/+459
|\ | | | | Enable a compiler plugin to use the async transform after patmat
| * 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} ```
* Merge pull request #139 from backuitist/patch-1Jason Zaugg2015-09-131-1/+1
|\ | | | | Typo
| * TypoBruno Bieth2015-08-181-1/+1
|/
* Merge pull request #134 from retronym/merge/2.10.x-to-master-20150730Jason Zaugg2015-07-300-0/+0
|\ | | | | Noop merge of 2.10.x to master.
| * Merge commit 'f9e170e3187f83c5d00e9ea8128fe2edf2bd371c' into ↵Jason Zaugg2015-07-300-0/+0
| |\ | | | | | | | | | merge/2.10.x-to-master-20150730
| | * [backport] Make nsc.Global based tests work under SBTJason Zaugg2015-07-301-17/+3
| | | | | | | | | | | | | | | | | | And remove unused code. (cherry picked from commit 7238bc1982cb1d87157c650115a2ae92a58430c9)
| | * [backport] Stop test compiler before code generationJason Zaugg2015-07-301-3/+3
| | | | | | | | | | | | | | | | | | | | | This avoids leaving .class files in the working directory after running the test. (cherry picked from commit 5bb93b0b7357259eb588437a45063bf43595028a)
| | * [backport] Avoid dead code warning with async(throw T)Jason Zaugg2015-07-303-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | By declararing the parameter of `async` as by-name. Fixes #150 (the bug in the original ticket.) (cherry picked from commit 4b1dbeef9ec73612867afc5dd9c925faa8cbc30d)
| | * [backport] Avoid dead code warnings in generated code.Jason Zaugg2015-07-303-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.)
| | * [backport] Cleanup code generation by avoiding redundant blocksJason Zaugg2015-07-302-19/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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. (cherry picked from commit de641dc265f34b06e17dfa7c64be00219f72b670)
| | * Merge pull request #124 from retronym/backport/sbt-bumpJason Zaugg2015-07-271-1/+1
| | |\ | | | | | | | | Update SBT for the warn command, now assumed by sbt-extras
| | | * Update SBT for the warn command, now assumed by sbt-extrasJason Zaugg2015-07-271-1/+1
| | | | | | | | | | | | | | | | (cherry picked from commit f6a5c93acb7628c4d169b778e386332c6d1bd99b)
* | | | Merge pull request #132 from retronym/ticket/105Jason Zaugg2015-07-306-24/+108
|\ \ \ \ | | | | | | | | | | Avoid dead code warnings for users of async.
| * | | | 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 #128 from scala/bump/0.9.6-2.11Jason Zaugg2015-07-301-1/+1
|\ \ \ \ | |/ / / |/| | | Bump to 0.9.6-SNAPSHOT
| * | | Bump to 0.9.6-SNAPSHOTbump/0.9.6-2.11Jason Zaugg2015-07-281-1/+1
|/ / /
* | | 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
* | | | Merge pull request #121 from retronym/ticket/119Jason Zaugg2015-07-271-1/+1
|\ \ \ \ | | | | | | | | | | Avoid leaking untyped trees out of macro
| * | | | 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
* | | | | Merge pull request #126 from retronym/merge/2.10.x-to-master-20150727Jason Zaugg2015-07-271-1/+1
|\ \ \ \ \ | |_|/ / / |/| | | | Merge 2.10.x to master
| * | | | Merge remote-tracking branch 'origin/2.10.x' into ↵Jason Zaugg2015-07-271-1/+1
|/| | | | | | |/ / | |/| | | | | | merge/2.10.x-to-master-20150727
| * | | Merge pull request #125 from retronym/topic/travis-bumpJason Zaugg2015-07-271-1/+1
| |\ \ \ | | |_|/ | |/| | Opt in to container based TravisCI
| | * | Opt in to container based TravisCIJason Zaugg2015-07-271-1/+1
| |/ /
| * | Merge pull request #118 from scala/bump/0.9.5-SNAPSHOT_2.10Jason Zaugg2015-07-071-1/+1
| |\ \ | | | | | | | | Bump version to v0.9.5-SNAPSHOT
| | * | Bump version to v0.9.5-SNAPSHOTbump/0.9.5-SNAPSHOT_2.10Jason Zaugg2015-07-071-1/+1
| |/ /
* | | Merge pull request #123 from retronym/topic/sbt-bumpJason Zaugg2015-07-271-1/+1
|\ \ \ | | |/ | |/| Update SBT to support the command, which is assumed by sbt-extras
| * | Update SBT for the warn command, now assumed by sbt-extrasJason Zaugg2015-07-271-1/+1
|/ /
* | Merge pull request #117 from scala/bump/0.9.5-SNAPSHOTJason Zaugg2015-07-071-1/+1
|\ \ | | | | | | Bump to 0.9.5-SNAPSHOT
| * | Bump to 0.9.5-SNAPSHOTbump/0.9.5-SNAPSHOTJason Zaugg2015-07-071-1/+1
|/ /
* | Merge pull request #116 from retronym/merge/2.10.x-to-master-20150707v0.9.4_2.11Jason Zaugg2015-07-070-0/+0
|\ \ | | | | | | noop merge of 2.10.x to master
| * | Merge remote-tracking branch 'origin/2.10.x' into ↵Jason Zaugg2015-07-070-0/+0
|/| | | |/ | | | | merge/2.10.x-to-master-20150707
| * Merge pull request #115 from retronym/backport/74v0.9.4_2.10Jason Zaugg2015-07-072-1/+46
| |\ | | | | | | Avoid compiler warning when awaiting Future[Unit]
| | * 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 (cherry picked from commit f3f058991b207a07041672a7e119422d9054788d)
| * | Merge pull request #113 from retronym/backport/104Jason Zaugg2015-07-062-1/+27
| |\ \ | | | | | | | | [backport] Avoid masking real errors with NotImplemented awaiting Future[Nothing]
| | * | [backport] Avoid masking real errors with NotImplemented awaiting ↵Jason Zaugg2015-07-062-1/+27
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | Future[Nothing] This commit disabled live variable analysis for intermediate values of type Nothing. Fixes #104 (cherry picked from commit 6353443a0adec384172c38efac3bc96b9d2cbad2)
* | | Merge pull request #114 from retronym/ticket/74Jason Zaugg2015-07-072-1/+46
|\ \ \ | | | | | | | | Avoid compiler warning when awaiting Future[Unit]
| * | | 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
* | | Merge pull request #112 from retronym/ticket/104Jason Zaugg2015-07-062-1/+27
|\ \ \ | | | | | | | | Avoid masking real errors with NotImplemented awaiting Future[Nothing]
| * | | 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
* | | Merge pull request #110 from retronym/merge/2.10.x-to-master-20150706Jason Zaugg2015-07-060-0/+0
|\ \ \ | | | | | | | | (noop) Merge 2.10.x to master
| * | | Merge remote-tracking branch 'origin/2.10.x' into ↵Jason Zaugg2015-07-060-0/+0
|/| | | | |/ / | | | | | | merge/2.10.x-to-master-20150706
| * | Merge pull request #108 from retronym/ticket/106-2.10.xJason Zaugg2015-07-062-2/+16
| |\ \ | | | | | | | | Fix compiler crash with value class in result position
| | * | Fix compiler crash with value class in result positionJason Zaugg2015-07-062-2/+16
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | We were leaking untyped trees out of the macro, which crashed in refchecks. This commit proactively typechecks the tree returned by `mkZero`. (cherry picked from commit f4275e22e000541eb619808723b70bd64b9b4873)