aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/pickling/TreePickler.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-03-08 09:52:01 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-18 11:15:47 +0100
commit3bcab098b641c7dfcf9f8788aacf942c06b52764 (patch)
tree77c698e8b0992dde78c85e50d2e0cad780e06a1b /src/dotty/tools/dotc/core/pickling/TreePickler.scala
parent1cd7d0082c93cead1749bcda51fd3b311fb45444 (diff)
downloaddotty-3bcab098b641c7dfcf9f8788aacf942c06b52764.tar.gz
dotty-3bcab098b641c7dfcf9f8788aacf942c06b52764.tar.bz2
dotty-3bcab098b641c7dfcf9f8788aacf942c06b52764.zip
Fix to pickling literals
Need to pickle the type, not the constant stored in the literal, because constant folding might have adapted the type, but leaves the constant value unchanged. An example is in pickleOK/unions.scala where a float 1.0f was adapted to Double, so should be pickled as a Double 1.0.
Diffstat (limited to 'src/dotty/tools/dotc/core/pickling/TreePickler.scala')
-rw-r--r--src/dotty/tools/dotc/core/pickling/TreePickler.scala9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/TreePickler.scala b/src/dotty/tools/dotc/core/pickling/TreePickler.scala
index 3ac2d0adc..3004043d5 100644
--- a/src/dotty/tools/dotc/core/pickling/TreePickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/TreePickler.scala
@@ -312,8 +312,13 @@ class TreePickler(pickler: TastyPickler) {
pickleTree(fun)
args.foreach(pickleTpt)
}
- case Literal(const) =>
- pickleConstant(const)
+ case Literal(const1) =>
+ pickleConstant {
+ tree.tpe match {
+ case ConstantType(const2) => const2
+ case _ => const1
+ }
+ }
case Super(qual, mix) =>
writeByte(SUPER)
withLength {