aboutsummaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2017-02-18 13:02:51 +0100
committerGitHub <noreply@github.com>2017-02-18 13:02:51 +0100
commit1946b36ca4abb7ba8264c18af95bc9c9c94f67ee (patch)
tree4ae886ac2836ac9095590dd0817aa8660504a71a /compiler
parent1183b57a014fdb730124037708e2de9ab7c2b128 (diff)
parentf04f8db9143dab8960d4577974856ee9a62d5909 (diff)
downloaddotty-1946b36ca4abb7ba8264c18af95bc9c9c94f67ee.tar.gz
dotty-1946b36ca4abb7ba8264c18af95bc9c9c94f67ee.tar.bz2
dotty-1946b36ca4abb7ba8264c18af95bc9c9c94f67ee.zip
Merge pull request #1972 from dotty-staging/fix/inline-errors
TreeMap/TreeAccumulator: proper context for inlined trees
Diffstat (limited to 'compiler')
-rw-r--r--compiler/src/dotty/tools/dotc/ast/Trees.scala11
-rw-r--r--compiler/src/dotty/tools/dotc/ast/tpd.scala5
2 files changed, 10 insertions, 6 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/Trees.scala b/compiler/src/dotty/tools/dotc/ast/Trees.scala
index bf11a442e..27be8c9d6 100644
--- a/compiler/src/dotty/tools/dotc/ast/Trees.scala
+++ b/compiler/src/dotty/tools/dotc/ast/Trees.scala
@@ -1077,6 +1077,13 @@ object Trees {
/** Hook to indicate that a transform of some subtree should be skipped */
protected def skipTransform(tree: Tree)(implicit ctx: Context): Boolean = false
+ /** For untyped trees, this is just the identity.
+ * For typed trees, a context derived form `ctx` that records `call` as the
+ * innermost enclosing call for which the inlined version is currently
+ * processed.
+ */
+ protected def inlineContext(call: Tree)(implicit ctx: Context): Context = ctx
+
abstract class TreeMap(val cpy: TreeCopier = inst.cpy) {
def transform(tree: Tree)(implicit ctx: Context): Tree =
@@ -1121,7 +1128,7 @@ object Trees {
case SeqLiteral(elems, elemtpt) =>
cpy.SeqLiteral(tree)(transform(elems), transform(elemtpt))
case Inlined(call, bindings, expansion) =>
- cpy.Inlined(tree)(call, transformSub(bindings), transform(expansion))
+ cpy.Inlined(tree)(call, transformSub(bindings), transform(expansion)(inlineContext(call)))
case TypeTree() =>
tree
case SingletonTypeTree(ref) =>
@@ -1225,7 +1232,7 @@ object Trees {
case SeqLiteral(elems, elemtpt) =>
this(this(x, elems), elemtpt)
case Inlined(call, bindings, expansion) =>
- this(this(x, bindings), expansion)
+ this(this(x, bindings), expansion)(inlineContext(call))
case TypeTree() =>
x
case SingletonTypeTree(ref) =>
diff --git a/compiler/src/dotty/tools/dotc/ast/tpd.scala b/compiler/src/dotty/tools/dotc/ast/tpd.scala
index ed268fda7..d1d886c55 100644
--- a/compiler/src/dotty/tools/dotc/ast/tpd.scala
+++ b/compiler/src/dotty/tools/dotc/ast/tpd.scala
@@ -933,10 +933,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
/** A key to be used in a context property that tracks enclosing inlined calls */
private val InlinedCalls = new Property.Key[List[Tree]]
- /** A context derived form `ctx` that records `call` as innermost enclosing
- * call for which the inlined version is currently processed.
- */
- def inlineContext(call: Tree)(implicit ctx: Context): Context =
+ override def inlineContext(call: Tree)(implicit ctx: Context): Context =
ctx.fresh.setProperty(InlinedCalls, call :: enclosingInlineds)
/** All enclosing calls that are currently inlined, from innermost to outermost */