File tree Expand file tree Collapse file tree 6 files changed +37
-5
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 6 files changed +37
-5
lines changed Original file line number Diff line number Diff line change @@ -38,5 +38,6 @@ object MigrationVersion:
3838 val ImportWildcard = MigrationVersion (future, future)
3939 val ImportRename = MigrationVersion (future, future)
4040 val ParameterEnclosedByParenthesis = MigrationVersion (future, future)
41+ val XmlLiteral = MigrationVersion (future, future)
4142
4243end MigrationVersion
Original file line number Diff line number Diff line change @@ -571,8 +571,16 @@ object Parsers {
571571
572572 object symbXMLBuilder extends xml.SymbolicXMLBuilder (this , true ) // DEBUG choices
573573
574- def xmlLiteral () : Tree = xmlp.xLiteral
575- def xmlLiteralPattern () : Tree = xmlp.xLiteralPattern
574+ def xmlLiteral () : Tree = xmlDeprecationWarning(xmlp.xLiteral)
575+ def xmlLiteralPattern () : Tree = xmlDeprecationWarning(xmlp.xLiteralPattern)
576+
577+ private def xmlDeprecationWarning (tree : Tree ): Tree =
578+ report.errorOrMigrationWarning(
579+ em """ XML literals are no longer supported.
580+ |See https://docs.scala-lang.org/scala3/reference/dropped-features/xml.html """ ,
581+ tree.srcPos,
582+ MigrationVersion .XmlLiteral )
583+ tree
576584
577585/* -------- COMBINATORS -------------------------------------------------------- */
578586
Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ object MarkupParsers {
277277 * | xmlTag1 '/' '>'
278278 */
279279 def element : Tree = {
280- val start = curOffset
280+ val start = curOffset // FIXME should be `curOffset - 1` (scalatest and tests/neg/i19100.scala must be updated)
281281 val (qname, attrMap) = xTag(())
282282 if (ch == '/' ) { // empty element
283283 xToken(" />" )
@@ -435,7 +435,7 @@ object MarkupParsers {
435435 * | Name [S] '/' '>'
436436 */
437437 def xPattern : Tree = {
438- var start = curOffset
438+ var start = curOffset // FIXME should be `curOffset - 1` (scalatest and tests/neg/i19100.scala must be updated)
439439 val qname = xName
440440 debugLastStartElement = (start, qname) :: debugLastStartElement
441441 xSpaceOpt()
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ import parsing.{Parser => ParserPhase}
1212import config .Printers .typr
1313import inlines .PrepareInlineable
1414import util .Stats .*
15+ import dotty .tools .dotc .config .Feature
16+ import dotty .tools .dotc .config .SourceVersion
1517
1618/**
1719 *
@@ -83,7 +85,7 @@ class TyperPhase(addRootImports: Boolean = true) extends Phase {
8385
8486 ctx.base.parserPhase match {
8587 case p : ParserPhase =>
86- if p.firstXmlPos.exists && ! defn.ScalaXmlPackageClass .exists then
88+ if p.firstXmlPos.exists && ! defn.ScalaXmlPackageClass .exists && Feature .sourceVersion == SourceVersion .future then
8789 report.error(
8890 """ To support XML literals, your project must depend on scala-xml.
8991 |See https://github.com/scala/scala-xml for more information.""" .stripMargin,
Original file line number Diff line number Diff line change 1+ -- Error: tests/neg/i19100.scala:4:3 -----------------------------------------------------------------------------------
2+ 4 | <foo/> match // error
3+ | ^^^^^
4+ | XML literals are no longer supported.
5+ | See https://docs.scala-lang.org/scala3/reference/dropped-features/xml.html
6+ -- Error: tests/neg/i19100.scala:5:10 ----------------------------------------------------------------------------------
7+ 5 | case <foo/> => 1 // error
8+ | ^^^^^
9+ | XML literals are no longer supported.
10+ | See https://docs.scala-lang.org/scala3/reference/dropped-features/xml.html
11+ -- Error: tests/neg/i19100.scala:6:3 -----------------------------------------------------------------------------------
12+ 6 | <bar></bar> // error
13+ | ^^^^^^^^^^
14+ | XML literals are no longer supported.
15+ | See https://docs.scala-lang.org/scala3/reference/dropped-features/xml.html
Original file line number Diff line number Diff line change 1+ import scala .language .future
2+
3+ def test =
4+ <foo /> match // error
5+ case <foo /> => 1 // error
6+ <bar ></bar > // error
You can’t perform that action at this time.
0 commit comments