@@ -21,26 +21,28 @@ object Constants {
2121 final val ClazzTag = 12
2222 // For supporting java enumerations inside java annotations (see ClassfileParser)
2323 final val EnumTag = 13
24+ final val ScalaSymbolTag = 14
2425
2526 case class Constant (value : Any ) extends printing.Showable {
2627 import java .lang .Double .doubleToRawLongBits
2728 import java .lang .Float .floatToRawIntBits
2829
2930 val tag : Int = value match {
30- case null => NullTag
31- case x : Unit => UnitTag
32- case x : Boolean => BooleanTag
33- case x : Byte => ByteTag
34- case x : Short => ShortTag
35- case x : Int => IntTag
36- case x : Long => LongTag
37- case x : Float => FloatTag
38- case x : Double => DoubleTag
39- case x : String => StringTag
40- case x : Char => CharTag
41- case x : Type => ClazzTag
42- case x : Symbol => EnumTag
43- case _ => throw new Error (" bad constant value: " + value + " of class " + value.getClass)
31+ case null => NullTag
32+ case x : Unit => UnitTag
33+ case x : Boolean => BooleanTag
34+ case x : Byte => ByteTag
35+ case x : Short => ShortTag
36+ case x : Int => IntTag
37+ case x : Long => LongTag
38+ case x : Float => FloatTag
39+ case x : Double => DoubleTag
40+ case x : String => StringTag
41+ case x : Char => CharTag
42+ case x : Type => ClazzTag
43+ case x : Symbol => EnumTag
44+ case x : scala.Symbol => ScalaSymbolTag
45+ case _ => throw new Error (" bad constant value: " + value + " of class " + value.getClass)
4446 }
4547
4648 def isByteRange : Boolean = isIntRange && Byte .MinValue <= intValue && intValue <= Byte .MaxValue
@@ -54,19 +56,20 @@ object Constants {
5456 def isAnyVal = UnitTag <= tag && tag <= DoubleTag
5557
5658 def tpe (implicit ctx : Context ): Type = tag match {
57- case UnitTag => defn.UnitType
58- case BooleanTag => defn.BooleanType
59- case ByteTag => defn.ByteType
60- case ShortTag => defn.ShortType
61- case CharTag => defn.CharType
62- case IntTag => defn.IntType
63- case LongTag => defn.LongType
64- case FloatTag => defn.FloatType
65- case DoubleTag => defn.DoubleType
66- case StringTag => defn.StringType
67- case NullTag => defn.NullType
68- case ClazzTag => defn.ClassType (typeValue)
69- case EnumTag => defn.EnumType (symbolValue)
59+ case UnitTag => defn.UnitType
60+ case BooleanTag => defn.BooleanType
61+ case ByteTag => defn.ByteType
62+ case ShortTag => defn.ShortType
63+ case CharTag => defn.CharType
64+ case IntTag => defn.IntType
65+ case LongTag => defn.LongType
66+ case FloatTag => defn.FloatType
67+ case DoubleTag => defn.DoubleType
68+ case StringTag => defn.StringType
69+ case NullTag => defn.NullType
70+ case ClazzTag => defn.ClassType (typeValue)
71+ case EnumTag => defn.EnumType (symbolValue)
72+ case ScalaSymbolTag => defn.ScalaSymbolType
7073 }
7174
7275 /** We need the equals method to take account of tags as well as values.
@@ -206,6 +209,7 @@ object Constants {
206209
207210 def typeValue : Type = value.asInstanceOf [Type ]
208211 def symbolValue : Symbol = value.asInstanceOf [Symbol ]
212+ def scalaSymbolValue : scala.Symbol = value.asInstanceOf [scala.Symbol ]
209213
210214 /**
211215 * Consider two `NaN`s to be identical, despite non-equality
0 commit comments