aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/ast/tpd.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-09-15 21:45:26 +0200
committerMartin Odersky <odersky@gmail.com>2016-10-02 16:12:28 +0200
commit53b165e69bb45f424184d02e76c520b67ee0c1d7 (patch)
tree2b4f6123890b520e69dc14fe297e4a89dd79eb81 /src/dotty/tools/dotc/ast/tpd.scala
parentbef012d32127e3d256d0ce31e1a2a27f7277f8d8 (diff)
downloaddotty-53b165e69bb45f424184d02e76c520b67ee0c1d7.tar.gz
dotty-53b165e69bb45f424184d02e76c520b67ee0c1d7.tar.bz2
dotty-53b165e69bb45f424184d02e76c520b67ee0c1d7.zip
Cleanups
Better comments and refactorings that move some things around so that less modules depend on Inliner.
Diffstat (limited to 'src/dotty/tools/dotc/ast/tpd.scala')
-rw-r--r--src/dotty/tools/dotc/ast/tpd.scala22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala
index 54005808f..8ba7bc54d 100644
--- a/src/dotty/tools/dotc/ast/tpd.scala
+++ b/src/dotty/tools/dotc/ast/tpd.scala
@@ -10,6 +10,7 @@ import util.Positions._, Types._, Contexts._, Constants._, Names._, Flags._
import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._, Symbols._
import Denotations._, Decorators._, DenotTransformers._
import collection.mutable
+import util.{Property, SourceFile, NoSource}
import typer.ErrorReporting._
import scala.annotation.tailrec
@@ -921,8 +922,25 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
}
}
- // ensure that constructors are fully applied?
- // ensure that normal methods are fully applied?
+ /** 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 =
+ ctx.fresh.setProperty(InlinedCalls, call :: enclosingInlineds)
+
+ /** All enclosing calls that are currently inlined, from innermost to outermost */
+ def enclosingInlineds(implicit ctx: Context): List[Tree] =
+ ctx.property(InlinedCalls).getOrElse(Nil)
+
+ /** The source file where the symbol of the `@inline` method referred to by `call`
+ * is defined
+ */
+ def sourceFile(call: Tree)(implicit ctx: Context) = {
+ val file = call.symbol.sourceFile
+ if (file != null && file.exists) new SourceFile(file) else NoSource
+ }
}