diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-06 14:55:30 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-10-02 16:11:21 +0200 |
commit | f8d7500b675e21568011e8e0077f42f4a5463b4b (patch) | |
tree | 917b302d96f56143435601fb58b741b5551af884 /src/dotty/tools/dotc/typer/Inliner.scala | |
parent | 19ab7ab10fabe7113f45063ffd2b6cc6abcc3329 (diff) | |
download | dotty-f8d7500b675e21568011e8e0077f42f4a5463b4b.tar.gz dotty-f8d7500b675e21568011e8e0077f42f4a5463b4b.tar.bz2 dotty-f8d7500b675e21568011e8e0077f42f4a5463b4b.zip |
Fix problem affecting recursive inlines
The previous check whether a method was an inlined method with a body
forced computation of the body, which led to problems when dealing with
recursive inline methods.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Inliner.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Inliner.scala | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/typer/Inliner.scala b/src/dotty/tools/dotc/typer/Inliner.scala index b59c33008..763d1ee94 100644 --- a/src/dotty/tools/dotc/typer/Inliner.scala +++ b/src/dotty/tools/dotc/typer/Inliner.scala @@ -37,13 +37,18 @@ object Inliner { def attachBody(inlineAnnot: Annotation, tree: => Tree)(implicit ctx: Context): Unit = inlineAnnot.tree.putAttachment(InlinedBody, new InlinedBody(tree)) - def inlinedBody(sym: SymDenotation)(implicit ctx: Context): Option[Tree] = - sym.getAnnotation(defn.InlineAnnot).get.tree - .getAttachment(InlinedBody).map(_.body) + private def inlinedBodyAttachment(sym: SymDenotation)(implicit ctx: Context): Option[InlinedBody] = + sym.getAnnotation(defn.InlineAnnot).get.tree.getAttachment(InlinedBody) + + def hasInlinedBody(sym: SymDenotation)(implicit ctx: Context): Boolean = + inlinedBodyAttachment(sym).isDefined + + def inlinedBody(sym: SymDenotation)(implicit ctx: Context): Tree = + inlinedBodyAttachment(sym).get.body def inlineCall(tree: Tree, pt: Type)(implicit ctx: Context): Tree = if (enclosingInlineds.length < ctx.settings.xmaxInlines.value) - new Inliner(tree, inlinedBody(tree.symbol).get).inlined(pt) + new Inliner(tree, inlinedBody(tree.symbol)).inlined(pt) else errorTree(tree, i"""Maximal number of successive inlines (${ctx.settings.xmaxInlines.value}) exceeded, | Maybe this is caused by a recursive inline method? |