summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2017-02-21 10:22:09 +0100
committerGitHub <noreply@github.com>2017-02-21 10:22:09 +0100
commit2f1e0c22ecd3b6e3886bd9bc94f27725e08324b8 (patch)
treeae951cbb2a1f6bd75d4a318559baa6236fca4b16 /src
parent13f7b2a975ee77520535598fd192376b4d4b235e (diff)
parent6fb382501f7a63f3227a18396a2af0c862e6ab1c (diff)
downloadscala-2f1e0c22ecd3b6e3886bd9bc94f27725e08324b8.tar.gz
scala-2f1e0c22ecd3b6e3886bd9bc94f27725e08324b8.tar.bz2
scala-2f1e0c22ecd3b6e3886bd9bc94f27725e08324b8.zip
Merge pull request #5704 from som-snytt/issue/10190-elide-string
SI-10190 Elide string to empty instead of null
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index dcffd7a6ab..f35dd6556f 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -342,12 +342,16 @@ abstract class UnCurry extends InfoTransform
* the whole tree with it.
*/
private def replaceElidableTree(tree: Tree): Tree = {
+ def elisionOf(t: Type): Tree = t.typeSymbol match {
+ case StringClass => Literal(Constant("")) setType t
+ case _ => gen.mkZero(t)
+ }
tree match {
case DefDef(_,_,_,_,_,rhs) =>
- val rhs1 = if (rhs == EmptyTree) rhs else Block(Nil, gen.mkZero(rhs.tpe)) setType rhs.tpe
+ val rhs1 = if (rhs == EmptyTree) rhs else Block(Nil, elisionOf(rhs.tpe)) setType rhs.tpe
deriveDefDef(tree)(_ => rhs1) setSymbol tree.symbol setType tree.tpe
case _ =>
- gen.mkZero(tree.tpe) setType tree.tpe
+ elisionOf(tree.tpe)
}
}