diff options
author | liu fengyun <liu@fengy.me> | 2017-01-30 02:34:16 +0100 |
---|---|---|
committer | liu fengyun <liu@fengy.me> | 2017-01-30 02:34:36 +0100 |
commit | 1231dd5abc0bd42403f5386460de2026e678e88b (patch) | |
tree | 3ce6ff4599f635c46caaaaddbaf11cc1013841ca /compiler | |
parent | 6e8933ccc40bbfe1a92c32c2d8314fd6facef12a (diff) | |
download | dotty-1231dd5abc0bd42403f5386460de2026e678e88b.tar.gz dotty-1231dd5abc0bd42403f5386460de2026e678e88b.tar.bz2 dotty-1231dd5abc0bd42403f5386460de2026e678e88b.zip |
fix incorrect flatten of thicket inside interpolated string in UntpdTreeMap
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/src/dotty/tools/dotc/ast/untpd.scala | 2 | ||||
-rw-r--r-- | compiler/test/dotty/tools/dotc/ast/UntypedTreeMapTest.scala | 32 |
2 files changed, 33 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/untpd.scala b/compiler/src/dotty/tools/dotc/ast/untpd.scala index f3ffce8f8..37dc32c0e 100644 --- a/compiler/src/dotty/tools/dotc/ast/untpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/untpd.scala @@ -476,7 +476,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { case SymbolLit(str) => cpy.SymbolLit(tree)(str) case InterpolatedString(id, segments) => - cpy.InterpolatedString(tree)(id, transform(segments)) + cpy.InterpolatedString(tree)(id, segments.map(transform(_))) case Function(args, body) => cpy.Function(tree)(transform(args), transform(body)) case InfixOp(left, op, right) => diff --git a/compiler/test/dotty/tools/dotc/ast/UntypedTreeMapTest.scala b/compiler/test/dotty/tools/dotc/ast/UntypedTreeMapTest.scala new file mode 100644 index 000000000..9e7402968 --- /dev/null +++ b/compiler/test/dotty/tools/dotc/ast/UntypedTreeMapTest.scala @@ -0,0 +1,32 @@ +package dotty.tools +package dotc +package ast + +import org.junit.Test +import org.junit.Assert._ + +import dotc.core.Contexts._ +import dotc.parsing.Parsers.Parser +import dotc.util.SourceFile + +class UntpdTreeMapTest extends DottyTest { + + import untpd._ + + def parse(code: String): Tree = { + val (_, stats) = new Parser(new SourceFile("<meta>", code.toCharArray)).templateStatSeq() + stats match { case List(stat) => stat; case stats => untpd.Thicket(stats) } + } + + @Test + def testMapInterpolatedString = { + val tree = parse(""" q"hello ${2017}!" """) + val identity = new UntypedTreeMap { + override def transform(tree: Tree)(implicit ctx: Context): Tree = tree match { + case _ => super.transform(tree) + } + } + + assertEquals(tree.toString, identity.transform(tree).toString) + } +} |