aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/ast/Desugar.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-09-09 21:41:56 +0200
committerMartin Odersky <odersky@gmail.com>2016-10-02 16:11:21 +0200
commit184296f694d3623098864b8313b2ed7ccf7380f1 (patch)
tree96ea0066fd86ffa4505b84c8b667c4c7e599cd14 /src/dotty/tools/dotc/ast/Desugar.scala
parentb1cda4fadcb586a82b546751d5cc426cd5382cd5 (diff)
downloaddotty-184296f694d3623098864b8313b2ed7ccf7380f1.tar.gz
dotty-184296f694d3623098864b8313b2ed7ccf7380f1.tar.bz2
dotty-184296f694d3623098864b8313b2ed7ccf7380f1.zip
Inline argument closures to inline methods
If an argumnet to an inline method refers to a closure that is the result of eta-expanding another inline method inline the argument method.
Diffstat (limited to 'src/dotty/tools/dotc/ast/Desugar.scala')
-rw-r--r--src/dotty/tools/dotc/ast/Desugar.scala10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala
index 4e27da2ca..ecb6a3212 100644
--- a/src/dotty/tools/dotc/ast/Desugar.scala
+++ b/src/dotty/tools/dotc/ast/Desugar.scala
@@ -607,11 +607,17 @@ object desugar {
* ==>
* def $anonfun(params) = body
* Closure($anonfun)
+ *
+ * If `inlineable` is true, tag $anonfun with an @inline annotation.
*/
- def makeClosure(params: List[ValDef], body: Tree, tpt: Tree = TypeTree()) =
+ def makeClosure(params: List[ValDef], body: Tree, tpt: Tree = TypeTree(), inlineable: Boolean)(implicit ctx: Context) = {
+ var mods = synthetic
+ if (inlineable)
+ mods = mods.withAddedAnnotation(New(ref(defn.InlineAnnotType), Nil).withPos(body.pos))
Block(
- DefDef(nme.ANON_FUN, Nil, params :: Nil, tpt, body).withMods(synthetic),
+ DefDef(nme.ANON_FUN, Nil, params :: Nil, tpt, body).withMods(mods),
Closure(Nil, Ident(nme.ANON_FUN), EmptyTree))
+ }
/** If `nparams` == 1, expand partial function
*