aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/ast/Desugar.scala
diff options
context:
space:
mode:
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
*