File tree 6 files changed +37
-5
lines changed
compiler/src/dotty/tools/dotc
6 files changed +37
-5
lines changed Original file line number Diff line number Diff line change @@ -38,5 +38,6 @@ object MigrationVersion:
38
38
val ImportWildcard = MigrationVersion (future, future)
39
39
val ImportRename = MigrationVersion (future, future)
40
40
val ParameterEnclosedByParenthesis = MigrationVersion (future, future)
41
+ val XmlLiteral = MigrationVersion (future, future)
41
42
42
43
end MigrationVersion
Original file line number Diff line number Diff line change @@ -571,8 +571,16 @@ object Parsers {
571
571
572
572
object symbXMLBuilder extends xml.SymbolicXMLBuilder (this , true ) // DEBUG choices
573
573
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
576
584
577
585
/* -------- COMBINATORS -------------------------------------------------------- */
578
586
Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ object MarkupParsers {
277
277
* | xmlTag1 '/' '>'
278
278
*/
279
279
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)
281
281
val (qname, attrMap) = xTag(())
282
282
if (ch == '/' ) { // empty element
283
283
xToken(" />" )
@@ -435,7 +435,7 @@ object MarkupParsers {
435
435
* | Name [S] '/' '>'
436
436
*/
437
437
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)
439
439
val qname = xName
440
440
debugLastStartElement = (start, qname) :: debugLastStartElement
441
441
xSpaceOpt()
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ import parsing.{Parser => ParserPhase}
12
12
import config .Printers .typr
13
13
import inlines .PrepareInlineable
14
14
import util .Stats .*
15
+ import dotty .tools .dotc .config .Feature
16
+ import dotty .tools .dotc .config .SourceVersion
15
17
16
18
/**
17
19
*
@@ -83,7 +85,7 @@ class TyperPhase(addRootImports: Boolean = true) extends Phase {
83
85
84
86
ctx.base.parserPhase match {
85
87
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
87
89
report.error(
88
90
""" To support XML literals, your project must depend on scala-xml.
89
91
|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