diff options
author | Martin Odersky <odersky@gmail.com> | 2015-08-23 23:09:53 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-08-23 23:10:01 +0200 |
commit | 5b454b1070c3018203263f3bda21db217ed84f3f (patch) | |
tree | b78860de7d685397273922979f8c256f830b353d /src/dotty/tools/dotc/transform/Literalize.scala | |
parent | 5710272caea25014ac36517543a85f07c5f801d1 (diff) | |
download | dotty-5b454b1070c3018203263f3bda21db217ed84f3f.tar.gz dotty-5b454b1070c3018203263f3bda21db217ed84f3f.tar.bz2 dotty-5b454b1070c3018203263f3bda21db217ed84f3f.zip |
Make literalize work for TermRefs of constant type.
Diffstat (limited to 'src/dotty/tools/dotc/transform/Literalize.scala')
-rw-r--r-- | src/dotty/tools/dotc/transform/Literalize.scala | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/transform/Literalize.scala b/src/dotty/tools/dotc/transform/Literalize.scala index 4a223e912..f33baa52b 100644 --- a/src/dotty/tools/dotc/transform/Literalize.scala +++ b/src/dotty/tools/dotc/transform/Literalize.scala @@ -51,9 +51,13 @@ class Literalize extends MiniPhaseTransform { thisTransform => * Revisit this issue once we have implemented `inline`. Then we can demand * purity of the prefix unless the selection goes to an inline val. */ - def literalize(tree: Tree)(implicit ctx: Context): Tree = tree.tpe match { - case ConstantType(value) if isIdempotentExpr(tree) => Literal(value) - case _ => tree + def literalize(tree: Tree)(implicit ctx: Context): Tree = { + def recur(tp: Type): Tree = tp match { + case ConstantType(value) if isIdempotentExpr(tree) => Literal(value) + case tp: TermRef if tp.symbol.isStable => recur(tp.info.widenExpr) + case _ => tree + } + recur(tree.tpe) } override def transformIdent(tree: Ident)(implicit ctx: Context, info: TransformerInfo): Tree = |