diff options
author | Martin Odersky <odersky@gmail.com> | 2014-04-22 08:48:41 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-05-08 21:51:46 +0200 |
commit | 79632fb0eeb6adb82739e41cae671d698278aab9 (patch) | |
tree | 5ff6d311105108be4243b606a6977c5d0ba7fd84 /src | |
parent | 3ae84523f96d36afa922c9655d88b60417d0d42d (diff) | |
download | dotty-79632fb0eeb6adb82739e41cae671d698278aab9.tar.gz dotty-79632fb0eeb6adb82739e41cae671d698278aab9.tar.bz2 dotty-79632fb0eeb6adb82739e41cae671d698278aab9.zip |
Avoid retyping of Literals
Literals need to be promoted as is, because constant folding might
have changed the type of the literal to the expected type. E.g. in
val x: Byte = 2
The literal 2 will have type `Byte(2)` but its underlying constant will still be `Int(2)`.
So re-typing would give the wrong type.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/typer/ReTyper.scala | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/typer/ReTyper.scala b/src/dotty/tools/dotc/typer/ReTyper.scala index 7c2cd5b17..8d8134781 100644 --- a/src/dotty/tools/dotc/typer/ReTyper.scala +++ b/src/dotty/tools/dotc/typer/ReTyper.scala @@ -40,6 +40,9 @@ class ReTyper extends Typer { untpd.cpy.SelectFromTypeTree(tree, qual1, tree.name).withType(tree.typeOpt) } + override def typedLiteral(tree: untpd.Literal)(implicit ctc: Context): Literal = + promote(tree) + override def typedTypeTree(tree: untpd.TypeTree, pt: Type)(implicit ctx: Context): TypeTree = promote(tree) |