diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-24 19:13:20 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-09-24 19:16:29 +0200 |
commit | 962377ebc23a4c6a2757bee99e6558dd6a93c067 (patch) | |
tree | 19134d4bfb0e804110b74c623e2460f51891af2a /src/dotty/tools/dotc/ast/untpd.scala | |
parent | e2e1e8a43123de3c5594bad24af486b730e0b3c7 (diff) | |
download | dotty-962377ebc23a4c6a2757bee99e6558dd6a93c067.tar.gz dotty-962377ebc23a4c6a2757bee99e6558dd6a93c067.tar.bz2 dotty-962377ebc23a4c6a2757bee99e6558dd6a93c067.zip |
Make InterpolatedString conform to ordering requirement
Arrange its sub-elements so that they appear strictly left to right.
Diffstat (limited to 'src/dotty/tools/dotc/ast/untpd.scala')
-rw-r--r-- | src/dotty/tools/dotc/ast/untpd.scala | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/ast/untpd.scala b/src/dotty/tools/dotc/ast/untpd.scala index fdc4be823..7e1892253 100644 --- a/src/dotty/tools/dotc/ast/untpd.scala +++ b/src/dotty/tools/dotc/ast/untpd.scala @@ -35,7 +35,13 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { case class ParsedTry(expr: Tree, handler: Tree, finalizer: Tree) extends TermTree case class SymbolLit(str: String) extends TermTree - case class InterpolatedString(id: TermName, strings: List[Literal], elems: List[Tree]) extends TermTree + + /** An interpolated string + * @param segments a list of two element tickets consisting of string literal and argument tree, + * possibly with a simple string literal as last element of the list + */ + case class InterpolatedString(id: TermName, segments: List[Tree]) extends TermTree + case class Function(args: List[Tree], body: Tree) extends Tree { override def isTerm = body.isTerm override def isType = body.isType @@ -305,9 +311,9 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { case tree: SymbolLit if str == tree.str => tree case _ => untpd.SymbolLit(str).withPos(tree.pos) } - def InterpolatedString(tree: Tree)(id: TermName, strings: List[Literal], elems: List[Tree]) = tree match { - case tree: InterpolatedString if (id eq tree.id) && (strings eq tree.strings) && (elems eq tree.elems) => tree - case _ => untpd.InterpolatedString(id, strings, elems).withPos(tree.pos) + def InterpolatedString(tree: Tree)(id: TermName, segments: List[Tree]) = tree match { + case tree: InterpolatedString if (id eq tree.id) && (segments eq tree.segments) => tree + case _ => untpd.InterpolatedString(id, segments).withPos(tree.pos) } def Function(tree: Tree)(args: List[Tree], body: Tree) = tree match { case tree: Function if (args eq tree.args) && (body eq tree.body) => tree @@ -379,8 +385,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { cpy.ParsedTry(tree)(transform(expr), transform(handler), transform(finalizer)) case SymbolLit(str) => cpy.SymbolLit(tree)(str) - case InterpolatedString(id, strings, elems) => - cpy.InterpolatedString(tree)(id, transformSub(strings), transform(elems)) + case InterpolatedString(id, segments) => + cpy.InterpolatedString(tree)(id, transform(segments)) case Function(args, body) => cpy.Function(tree)(transform(args), transform(body)) case InfixOp(left, op, right) => @@ -426,8 +432,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { this(this(this(x, expr), handler), finalizer) case SymbolLit(str) => x - case InterpolatedString(id, strings, elems) => - this(this(x, strings), elems) + case InterpolatedString(id, segments) => + this(x, segments) case Function(args, body) => this(this(x, args), body) case InfixOp(left, op, right) => |