diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-01 17:31:10 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-10-02 16:11:21 +0200 |
commit | 8a3762a62d12b7f57de27c840425184df56b2689 (patch) | |
tree | 35db0a16b8361568290c20dcb5d215af7178cc62 /src/dotty/tools/dotc/typer/Typer.scala | |
parent | d63a6ba8540fb8ea7d01350ea68ff1ef0b53c5d4 (diff) | |
download | dotty-8a3762a62d12b7f57de27c840425184df56b2689.tar.gz dotty-8a3762a62d12b7f57de27c840425184df56b2689.tar.bz2 dotty-8a3762a62d12b7f57de27c840425184df56b2689.zip |
Add Inlined tree node
... to tag inlined calls. Perform typings and transformations
of inlined calls in a context that refers to the INlined node
in its InlinedCall property.
The idea is that we can use this to issue better error
positions. This remains to be implemented.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 007eaa468..dc41cc567 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -553,9 +553,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit } } + def typedBlockStats(stats: List[untpd.Tree])(implicit ctx: Context): (Context, List[tpd.Tree]) = + (index(stats), typedStats(stats, ctx.owner)) + def typedBlock(tree: untpd.Block, pt: Type)(implicit ctx: Context) = track("typedBlock") { - val exprCtx = index(tree.stats) - val stats1 = typedStats(tree.stats, ctx.owner) + val (exprCtx, stats1) = typedBlockStats(tree.stats) val ept = if (tree.isInstanceOf[untpd.InfixOpBlock]) // Right-binding infix operations are expanded to InfixBlocks, which may be followed by arguments. @@ -943,6 +945,13 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit assignType(cpy.SeqLiteral(tree)(elems1, elemtpt1), elems1, elemtpt1) } + def typedInlined(tree: untpd.Inlined, pt: Type)(implicit ctx: Context): Inlined = { + val (exprCtx, bindings1) = typedBlockStats(tree.bindings) + val expansion1 = typed(tree.expansion, pt)(Inliner.inlineContext(tree)(exprCtx)) + cpy.Inlined(tree)(tree.call, bindings1.asInstanceOf[List[MemberDef]], expansion1) + .withType(expansion1.tpe) + } + def typedTypeTree(tree: untpd.TypeTree, pt: Type)(implicit ctx: Context): TypeTree = track("typedTypeTree") { if (tree.original.isEmpty) tree match { @@ -1429,6 +1438,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit case tree: untpd.TypeApply => typedTypeApply(tree, pt) case tree: untpd.Super => typedSuper(tree, pt) case tree: untpd.SeqLiteral => typedSeqLiteral(tree, pt) + case tree: untpd.Inlined => typedInlined(tree, pt) case tree: untpd.TypeTree => typedTypeTree(tree, pt) case tree: untpd.SingletonTypeTree => typedSingletonTypeTree(tree) case tree: untpd.AndTypeTree => typedAndTypeTree(tree) |