diff --git a/compiler/src/dotty/tools/dotc/config/MigrationVersion.scala b/compiler/src/dotty/tools/dotc/config/MigrationVersion.scala
index 851e34c298db..d4afc599896c 100644
--- a/compiler/src/dotty/tools/dotc/config/MigrationVersion.scala
+++ b/compiler/src/dotty/tools/dotc/config/MigrationVersion.scala
@@ -38,5 +38,6 @@ object MigrationVersion:
val ImportWildcard = MigrationVersion(future, future)
val ImportRename = MigrationVersion(future, future)
val ParameterEnclosedByParenthesis = MigrationVersion(future, future)
+ val XmlLiteral = MigrationVersion(future, future)
end MigrationVersion
diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
index fc61be0b0e83..47b7ffbbc840 100644
--- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -571,8 +571,16 @@ object Parsers {
object symbXMLBuilder extends xml.SymbolicXMLBuilder(this, true) // DEBUG choices
- def xmlLiteral() : Tree = xmlp.xLiteral
- def xmlLiteralPattern() : Tree = xmlp.xLiteralPattern
+ def xmlLiteral() : Tree = xmlDeprecationWarning(xmlp.xLiteral)
+ def xmlLiteralPattern() : Tree = xmlDeprecationWarning(xmlp.xLiteralPattern)
+
+ private def xmlDeprecationWarning(tree: Tree): Tree =
+ report.errorOrMigrationWarning(
+ em"""XML literals are no longer supported.
+ |See https://docs.scala-lang.org/scala3/reference/dropped-features/xml.html""",
+ tree.srcPos,
+ MigrationVersion.XmlLiteral)
+ tree
/* -------- COMBINATORS -------------------------------------------------------- */
diff --git a/compiler/src/dotty/tools/dotc/parsing/xml/MarkupParsers.scala b/compiler/src/dotty/tools/dotc/parsing/xml/MarkupParsers.scala
index 5567b4f569d5..22ef15b6f497 100644
--- a/compiler/src/dotty/tools/dotc/parsing/xml/MarkupParsers.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/xml/MarkupParsers.scala
@@ -277,7 +277,7 @@ object MarkupParsers {
* | xmlTag1 '/' '>'
*/
def element: Tree = {
- val start = curOffset
+ val start = curOffset // FIXME should be `curOffset - 1` (scalatest and tests/neg/i19100.scala must be updated)
val (qname, attrMap) = xTag(())
if (ch == '/') { // empty element
xToken("/>")
@@ -435,7 +435,7 @@ object MarkupParsers {
* | Name [S] '/' '>'
*/
def xPattern: Tree = {
- var start = curOffset
+ var start = curOffset // FIXME should be `curOffset - 1` (scalatest and tests/neg/i19100.scala must be updated)
val qname = xName
debugLastStartElement = (start, qname) :: debugLastStartElement
xSpaceOpt()
diff --git a/compiler/src/dotty/tools/dotc/typer/TyperPhase.scala b/compiler/src/dotty/tools/dotc/typer/TyperPhase.scala
index b16447ecb15b..f7afc7a7e0a7 100644
--- a/compiler/src/dotty/tools/dotc/typer/TyperPhase.scala
+++ b/compiler/src/dotty/tools/dotc/typer/TyperPhase.scala
@@ -12,6 +12,8 @@ import parsing.{Parser => ParserPhase}
import config.Printers.typr
import inlines.PrepareInlineable
import util.Stats.*
+import dotty.tools.dotc.config.Feature
+import dotty.tools.dotc.config.SourceVersion
/**
*
@@ -83,7 +85,7 @@ class TyperPhase(addRootImports: Boolean = true) extends Phase {
ctx.base.parserPhase match {
case p: ParserPhase =>
- if p.firstXmlPos.exists && !defn.ScalaXmlPackageClass.exists then
+ if p.firstXmlPos.exists && !defn.ScalaXmlPackageClass.exists && Feature.sourceVersion == SourceVersion.future then
report.error(
"""To support XML literals, your project must depend on scala-xml.
|See https://github.com/scala/scala-xml for more information.""".stripMargin,
diff --git a/tests/neg/i19100.check b/tests/neg/i19100.check
new file mode 100644
index 000000000000..e6ff80e450ab
--- /dev/null
+++ b/tests/neg/i19100.check
@@ -0,0 +1,15 @@
+-- Error: tests/neg/i19100.scala:4:3 -----------------------------------------------------------------------------------
+4 | match // error
+ | ^^^^^
+ | XML literals are no longer supported.
+ | See https://docs.scala-lang.org/scala3/reference/dropped-features/xml.html
+-- Error: tests/neg/i19100.scala:5:10 ----------------------------------------------------------------------------------
+5 | case => 1 // error
+ | ^^^^^
+ | XML literals are no longer supported.
+ | See https://docs.scala-lang.org/scala3/reference/dropped-features/xml.html
+-- Error: tests/neg/i19100.scala:6:3 -----------------------------------------------------------------------------------
+6 | // error
+ | ^^^^^^^^^^
+ | XML literals are no longer supported.
+ | See https://docs.scala-lang.org/scala3/reference/dropped-features/xml.html
diff --git a/tests/neg/i19100.scala b/tests/neg/i19100.scala
new file mode 100644
index 000000000000..2f15046b8561
--- /dev/null
+++ b/tests/neg/i19100.scala
@@ -0,0 +1,6 @@
+import scala.language.future
+
+def test =
+ match // error
+ case => 1 // error
+ // error