diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index c08111c99e09..86c58118372e 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1461,7 +1461,9 @@ object desugar { case PolyFunction(targs, body) => makePolyFunction(targs, body) orElse tree case SymbolLit(str) => - Literal(Constant(scala.Symbol(str))) + Apply( + ref(defn.ScalaSymbolClass.companionModule.termRef), + Literal(Constant(str)) :: Nil) case InterpolatedString(id, segments) => val strs = segments map { case ts: Thicket => ts.trees.head diff --git a/compiler/src/dotty/tools/dotc/core/Constants.scala b/compiler/src/dotty/tools/dotc/core/Constants.scala index 048fca394c95..81b876cb5d00 100644 --- a/compiler/src/dotty/tools/dotc/core/Constants.scala +++ b/compiler/src/dotty/tools/dotc/core/Constants.scala @@ -22,7 +22,6 @@ object Constants { final val ClazzTag = 12 // For supporting java enumerations inside java annotations (see ClassfileParser) final val EnumTag = 13 - final val ScalaSymbolTag = 14 class Constant(val value: Any, val tag: Int) extends printing.Showable with Product1[Any] { import java.lang.Double.doubleToRawLongBits @@ -52,7 +51,6 @@ object Constants { case NullTag => defn.NullType case ClazzTag => defn.ClassType(typeValue) case EnumTag => defn.EnumType(symbolValue) - case ScalaSymbolTag => defn.ScalaSymbolType } /** We need the equals method to take account of tags as well as values. @@ -193,7 +191,6 @@ object Constants { def typeValue: Type = value.asInstanceOf[Type] def symbolValue: Symbol = value.asInstanceOf[Symbol] - def scalaSymbolValue: scala.Symbol = value.asInstanceOf[scala.Symbol] /** * Consider two `NaN`s to be identical, despite non-equality @@ -241,7 +238,6 @@ object Constants { def apply(x: Char): Constant = new Constant(x, CharTag) def apply(x: Type): Constant = new Constant(x, ClazzTag) def apply(x: Symbol): Constant = new Constant(x, EnumTag) - def apply(x: scala.Symbol): Constant = new Constant(x, ScalaSymbolTag) def apply(value: Any): Constant = new Constant(value, value match { @@ -258,7 +254,6 @@ object Constants { case x: Char => CharTag case x: Type => ClazzTag case x: Symbol => EnumTag - case x: scala.Symbol => ScalaSymbolTag } ) diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index f0d6177e09b0..82f520a3af3f 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -694,9 +694,6 @@ class Definitions { @threadUnsafe lazy val ScalaSymbolType: TypeRef = ctx.requiredClassRef("scala.Symbol") def ScalaSymbolClass(implicit ctx: Context): ClassSymbol = ScalaSymbolType.symbol.asClass - def ScalaSymbolModule(implicit ctx: Context): Symbol = ScalaSymbolClass.companionModule - @threadUnsafe lazy val ScalaSymbolModule_applyR: TermRef = ScalaSymbolModule.requiredMethodRef(nme.apply, List(StringType)) - def ScalaSymbolModule_apply(implicit ctx: Context): Symbol = ScalaSymbolModule_applyR.symbol @threadUnsafe lazy val DynamicType: TypeRef = ctx.requiredClassRef("scala.Dynamic") def DynamicClass(implicit ctx: Context): ClassSymbol = DynamicType.symbol.asClass diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala b/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala index efb31dfab3ef..cf4718fe3961 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala @@ -140,7 +140,6 @@ Standard-Section: "ASTs" TopLevelStat* NULLconst -- null CLASSconst Type -- classOf[Type] ENUMconst Path -- An enum constant - SYMBOLconst NameRef -- A symbol literal (todo: drop?) Type = Path -- Paths represent both types and terms TYPEREFdirect sym_ASTRef -- A reference to a local symbol (without a prefix). Reference is to definition node of symbol. @@ -250,7 +249,7 @@ Standard Section: "Comments" Comment* object TastyFormat { final val header: Array[Int] = Array(0x5C, 0xA1, 0xAB, 0x1F) - val MajorVersion: Int = 14 + val MajorVersion: Int = 15 val MinorVersion: Int = 0 /** Tags used to serialize names */ @@ -352,7 +351,6 @@ object TastyFormat { final val STRINGconst = 64 final val IMPORTED = 65 final val RENAMED = 66 - final val SYMBOLconst = 67 // Cat. 3: tag AST @@ -462,7 +460,7 @@ object TastyFormat { /** Useful for debugging */ def isLegalTag(tag: Int): Boolean = firstSimpleTreeTag <= tag && tag <= EXPORTED || - firstNatTreeTag <= tag && tag <= SYMBOLconst || + firstNatTreeTag <= tag && tag <= RENAMED || firstASTTreeTag <= tag && tag <= BOUNDED || firstNatASTTreeTag <= tag && tag <= NAMEDARG || firstLengthTreeTag <= tag && tag <= MATCHtpt || @@ -636,7 +634,6 @@ object TastyFormat { case SUPER => "SUPER" case CLASSconst => "CLASSconst" case ENUMconst => "ENUMconst" - case SYMBOLconst => "SYMBOLconst" case SINGLETONtpt => "SINGLETONtpt" case SUPERtype => "SUPERtype" case TERMREFin => "TERMREFin" diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala index b23578c5abae..5dbad3614d0f 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -130,9 +130,6 @@ class TreePickler(pickler: TastyPickler) { case EnumTag => writeByte(ENUMconst) pickleType(c.symbolValue.termRef) - case ScalaSymbolTag => - writeByte(SYMBOLconst) - pickleName(c.scalaSymbolValue.name.toTermName) } def pickleType(tpe0: Type, richTypes: Boolean = false)(implicit ctx: Context): Unit = { diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 8eb233d321d8..98132e6d4bcd 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -266,8 +266,6 @@ class TreeUnpickler(reader: TastyReader, Constant(readType()) case ENUMconst => Constant(readTermRef().termSymbol) - case SYMBOLconst => - Constant(scala.Symbol(readName().toString)) } /** Read a type */ diff --git a/compiler/src/dotty/tools/dotc/parsing/Tokens.scala b/compiler/src/dotty/tools/dotc/parsing/Tokens.scala index 6d8ee46a5d54..6f20c80793ee 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Tokens.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Tokens.scala @@ -209,8 +209,8 @@ object Tokens extends TokensCommon { final val allTokens: TokenSet = tokenRange(minToken, maxToken) final val simpleLiteralTokens: TokenSet = - tokenRange(CHARLIT, STRINGLIT) | BitSet(TRUE, FALSE, QUOTEID) // TODO: drop QUOTEID when symbol literals are gone - final val literalTokens: TokenSet = simpleLiteralTokens | BitSet(INTERPOLATIONID, NULL) + tokenRange(CHARLIT, STRINGLIT) | BitSet(TRUE, FALSE) + final val literalTokens: TokenSet = simpleLiteralTokens | BitSet(INTERPOLATIONID, QUOTEID, NULL) // TODO: drop QUOTEID when symbol literals are gone final val atomicExprTokens: TokenSet = literalTokens | identifierTokens | BitSet( USCORE, NULL, THIS, SUPER, TRUE, FALSE, RETURN, QUOTEID, XMLSTART) diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 764b0d9178c8..b5fc8830d328 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -490,7 +490,6 @@ class PlainPrinter(_ctx: Context) extends Printer { case CharTag => literalText(s"'${escapedChar(const.charValue)}'") case LongTag => literalText(const.longValue.toString + "L") case EnumTag => literalText(const.symbolValue.name.toString) - case ScalaSymbolTag => literalText("'" + const.scalaSymbolValue.name.toString) case _ => literalText(String.valueOf(const.value)) } diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala b/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala index 7afe4afea413..afe9622d25d8 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala @@ -1444,8 +1444,6 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util. if (x.tag == Constants.StringTag) Some(x.stringValue) else None def matchConstant_ClassTag(x: Constant): Option[Type] = if (x.tag == Constants.ClazzTag) Some(x.typeValue) else None - def matchConstant_Symbol(x: Constant): Option[scala.Symbol] = - if (x.tag == Constants.ScalaSymbolTag) Some(x.scalaSymbolValue) else None def Constant_Unit_apply(): Constant = Constants.Constant(()) def Constant_Null_apply(): Constant = Constants.Constant(null) @@ -1459,7 +1457,6 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util. def Constant_Double_apply(x: Double): Constant = Constants.Constant(x) def Constant_String_apply(x: String): Constant = Constants.Constant(x) def Constant_ClassTag_apply(x: scala.reflect.ClassTag[_]): Constant = Constants.Constant(x) - def Constant_Symbol_apply(x: scala.Symbol): Constant = Constants.Constant(x) // // SYMBOLS diff --git a/compiler/src/dotty/tools/dotc/transform/Erasure.scala b/compiler/src/dotty/tools/dotc/transform/Erasure.scala index 551429b3b959..55e8008f0363 100644 --- a/compiler/src/dotty/tools/dotc/transform/Erasure.scala +++ b/compiler/src/dotty/tools/dotc/transform/Erasure.scala @@ -386,10 +386,6 @@ object Erasure { tree.withType(tree.typeOpt) else if (tree.const.tag == Constants.ClazzTag) Literal(Constant(erasure(tree.const.typeValue))) - else if (tree.const.tag == Constants.ScalaSymbolTag) - ref(defn.ScalaSymbolModule) - .select(defn.ScalaSymbolModule_apply) - .appliedTo(Literal(Constant(tree.const.scalaSymbolValue.name))) else super.typedLiteral(tree) diff --git a/docs/docs/internals/syntax.md b/docs/docs/internals/syntax.md index e156394143fa..39c03e30af66 100644 --- a/docs/docs/internals/syntax.md +++ b/docs/docs/internals/syntax.md @@ -121,9 +121,9 @@ SimpleLiteral ::= [‘-’] integerLiteral | booleanLiteral | characterLiteral | stringLiteral - | symbolLiteral Literal ::= SimpleLiteral | processedStringLiteral + | symbolLiteral | ‘null’ QualId ::= id {‘.’ id} diff --git a/library/src/scala/tasty/reflect/ConstantOps.scala b/library/src/scala/tasty/reflect/ConstantOps.scala index 75bd46a70287..98585d52ac38 100644 --- a/library/src/scala/tasty/reflect/ConstantOps.scala +++ b/library/src/scala/tasty/reflect/ConstantOps.scala @@ -141,16 +141,5 @@ trait ConstantOps extends Core { def unapply(constant: Constant): Option[Type] = kernel.matchConstant_ClassTag(constant) } - - /** Module of scala.Symbol literals */ - object Symbol { - /** scala.Symbol literal */ - def apply(x: scala.Symbol): Constant = - kernel.Constant_Symbol_apply(x) - - /** Extractor for scala.Symbol literals */ - def unapply(constant: Constant): Option[scala.Symbol] = - kernel.matchConstant_Symbol(constant) - } } } diff --git a/library/src/scala/tasty/reflect/Kernel.scala b/library/src/scala/tasty/reflect/Kernel.scala index b36d4e0ff343..e8ee85bd983e 100644 --- a/library/src/scala/tasty/reflect/Kernel.scala +++ b/library/src/scala/tasty/reflect/Kernel.scala @@ -1184,7 +1184,6 @@ trait Kernel { def matchConstant_Double(constant: Constant): Option[Double] def matchConstant_String(constant: Constant): Option[String] def matchConstant_ClassTag(constant: Constant): Option[Type] - def matchConstant_Symbol(constant: Constant): Option[scala.Symbol] def Constant_Unit_apply(): Constant def Constant_Null_apply(): Constant @@ -1198,7 +1197,6 @@ trait Kernel { def Constant_Double_apply(x: Double): Constant def Constant_String_apply(x: String): Constant def Constant_ClassTag_apply(x: scala.reflect.ClassTag[_]): Constant - def Constant_Symbol_apply(x: scala.Symbol): Constant // // SYMBOLS diff --git a/library/src/scala/tasty/reflect/Printers.scala b/library/src/scala/tasty/reflect/Printers.scala index 75a473cf45c5..2de540619ed9 100644 --- a/library/src/scala/tasty/reflect/Printers.scala +++ b/library/src/scala/tasty/reflect/Printers.scala @@ -301,7 +301,6 @@ trait Printers case Constant.Double(value) => this += "Constant.Double(" += value += ")" case Constant.String(value) => this += "Constant.String(\"" += value += "\")" case Constant.ClassTag(value) => this += "Constant.ClassTag(" += value += ")" - case Constant.Symbol(value) => this += "Constant.Symbol('" += value.name += ")" } def visitType(x: TypeOrBounds): Buffer = x match { @@ -1390,8 +1389,6 @@ trait Printers case Constant.ClassTag(v) => this += "classOf" inSquare(printType(v)) - case Constant.Symbol(v) => - this += highlightLiteral("'" + v.name) } def printTypeOrBoundsTree(tpt: Tree)(implicit elideThis: Option[Symbol] = None): Buffer = tpt match { diff --git a/tests/neg/singletons.scala b/tests/neg/singletons.scala index efc73cbfa63c..48d0b7390123 100644 --- a/tests/neg/singletons.scala +++ b/tests/neg/singletons.scala @@ -5,5 +5,7 @@ object Test { val n: null = null // error: Null is not a legal singleton type + val sym: 'sym = 'sym // error: an identifier expected, but quoted identifier found + val foo: s"abc" = "abc" // error: not a legal singleton type } diff --git a/tests/neg/sip23-symbols.scala b/tests/neg/sip23-symbols.scala deleted file mode 100644 index cbec1f5816a2..000000000000 --- a/tests/neg/sip23-symbols.scala +++ /dev/null @@ -1,25 +0,0 @@ -object Test { - val sym0 = 's // error: no longer supported - //sym0: Symbol - sym0: 's // error // error: no longer supported - - //val sym1: 's = 's - //sym1: Symbol - //sym1: 's - - //final val sym2 = 's - //sym2: Symbol - //sym2: 's - - def id[T](t: T): T = t - type Identity[T] = T - def narrow[T <: Singleton](t: T): Identity[T] = t - - final val sym3 = id('s) // error: no longer supported - //sym3: Symbol - sym3: 's // error // error: no longer supported - - //val sym4 = narrow('s) - //sym4: Symbol - //sym4: 's -}