|
1 |
| -package dotty.tools.dotc |
| 1 | +package dotty.tools |
| 2 | +package dotc |
2 | 3 | package core
|
3 | 4 |
|
4 | 5 | import Types._, Symbols._, Contexts._
|
5 | 6 | import printing.Printer
|
6 | 7 | import printing.Texts.Text
|
| 8 | +import Decorators._ |
7 | 9 |
|
8 | 10 | object Constants {
|
9 | 11 |
|
@@ -161,25 +163,29 @@ object Constants {
|
161 | 163 | }
|
162 | 164 | case pt => pt
|
163 | 165 | }
|
164 |
| - val target = classBound(pt).typeSymbol |
165 |
| - if (target == tpe.typeSymbol) |
166 |
| - this |
167 |
| - else if ((target == defn.ByteClass) && isByteRange) |
168 |
| - Constant(byteValue) |
169 |
| - else if (target == defn.ShortClass && isShortRange) |
170 |
| - Constant(shortValue) |
171 |
| - else if (target == defn.CharClass && isCharRange) |
172 |
| - Constant(charValue) |
173 |
| - else if (target == defn.IntClass && isIntRange) |
174 |
| - Constant(intValue) |
175 |
| - else if (target == defn.LongClass && isLongRange) |
176 |
| - Constant(longValue) |
177 |
| - else if (target == defn.FloatClass && isFloatRange) |
178 |
| - Constant(floatValue) |
179 |
| - else if (target == defn.DoubleClass && isNumeric) |
180 |
| - Constant(doubleValue) |
181 |
| - else |
182 |
| - null |
| 166 | + pt match |
| 167 | + case ConstantType(value) if value == this => this |
| 168 | + case _: SingletonType => null |
| 169 | + case _ => |
| 170 | + val target = classBound(pt).typeSymbol |
| 171 | + if (target == tpe.typeSymbol) |
| 172 | + this |
| 173 | + else if ((target == defn.ByteClass) && isByteRange) |
| 174 | + Constant(byteValue) |
| 175 | + else if (target == defn.ShortClass && isShortRange) |
| 176 | + Constant(shortValue) |
| 177 | + else if (target == defn.CharClass && isCharRange) |
| 178 | + Constant(charValue) |
| 179 | + else if (target == defn.IntClass && isIntRange) |
| 180 | + Constant(intValue) |
| 181 | + else if (target == defn.LongClass && isLongRange) |
| 182 | + Constant(longValue) |
| 183 | + else if (target == defn.FloatClass && isFloatRange) |
| 184 | + Constant(floatValue) |
| 185 | + else if (target == defn.DoubleClass && isNumeric) |
| 186 | + Constant(doubleValue) |
| 187 | + else |
| 188 | + null |
183 | 189 | }
|
184 | 190 |
|
185 | 191 | def stringValue: String = value.toString
|
|
0 commit comments