diff --git a/community-build/community-projects/xml-interpolator b/community-build/community-projects/xml-interpolator index 9f30c806e644..0d8fffbf4b8e 160000 --- a/community-build/community-projects/xml-interpolator +++ b/community-build/community-projects/xml-interpolator @@ -1 +1 @@ -Subproject commit 9f30c806e644a0172985a99e282d764a5a338037 +Subproject commit 0d8fffbf4b8e8e4b72779b6b1fdccaf5e1db4b33 diff --git a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala index 5455c8b3f943..3d8e2868c4bb 100644 --- a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala +++ b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala @@ -2523,6 +2523,8 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler object Position extends PositionModule: def ofMacroExpansion: dotc.util.SourcePosition = MacroExpansion.position.getOrElse(dotc.util.SourcePosition(ctx.source, dotc.util.Spans.NoSpan)) + def apply(sourceFile: SourceFile, start: Int, end: Int): Position = + dotc.util.SourcePosition(sourceFile, dotc.util.Spans.Span(start, end)) end Position object PositionMethodsImpl extends PositionMethods: @@ -2566,9 +2568,6 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler def error(msg: String, pos: Position): Unit = dotc.report.error(msg, pos) - def error(msg: String, sourceFile: SourceFile, start: Int, end: Int): Unit = - dotc.report.error(msg, dotc.util.SourcePosition(sourceFile, dotc.util.Spans.Span(start, end))) - def throwError(msg: String): Nothing = error(msg) throw new scala.quoted.runtime.StopMacroExpansion @@ -2581,10 +2580,6 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler error(msg, pos) throw new scala.quoted.runtime.StopMacroExpansion - def throwError(msg: String, sourceFile: SourceFile, start: Int, end: Int): Nothing = - error(msg, sourceFile, start, end) - throw new scala.quoted.runtime.StopMacroExpansion - def warning(msg: String): Unit = dotc.report.warning(msg, Position.ofMacroExpansion) @@ -2594,9 +2589,6 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler def warning(msg: String, pos: Position): Unit = dotc.report.warning(msg, pos) - def warning(msg: String, sourceFile: SourceFile, start: Int, end: Int): Unit = - dotc.report.error(msg, dotc.util.SourcePosition(sourceFile, dotc.util.Spans.Span(start, end))) - end report type Documentation = dotc.core.Comments.Comment diff --git a/library/src/scala/quoted/Quotes.scala b/library/src/scala/quoted/Quotes.scala index 2f90f26913b4..b6c8ea21c9f6 100644 --- a/library/src/scala/quoted/Quotes.scala +++ b/library/src/scala/quoted/Quotes.scala @@ -4067,6 +4067,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => trait PositionModule { this: Position.type => /** Position of the expansion site of the macro */ def ofMacroExpansion: Position + + /** Create a new position in the source with the given range. The range must be contained in the file. */ + def apply(sourceFile: SourceFile, start: Int, end: Int): Position } /** Makes extension methods on `Position` available without any imports */ @@ -4169,9 +4172,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => /** Report an error message at the given position */ def error(msg: String, pos: Position): Unit - /** Report an error at a specific range of a file. The positions must be contained in the file. */ - def error(msg: String, source: SourceFile, start: Int, end: Int): Unit - /** Report an error at the position of the macro expansion and throws a StopMacroExpansion */ def throwError(msg: String): Nothing @@ -4181,9 +4181,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => /** Report an error message at the given position and throws a StopMacroExpansion */ def throwError(msg: String, pos: Position): Nothing - /** Report an error at a specific range of a file and throws a StopMacroExpansion. The positions must be contained in the file. */ - def throwError(msg: String, source: SourceFile, start: Int, end: Int): Nothing - /** Report a warning at the position of the macro expansion */ def warning(msg: String): Unit @@ -4193,9 +4190,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => /** Report an warning message at the given position */ def warning(msg: String, pos: Position): Unit - /** Emits a warning at a specific range of a file. The positions must be contained in the file. */ - def warning(msg: String, source: SourceFile, start: Int, end: Int): Unit - } diff --git a/tests/neg-macros/tasty-macro-positions/quoted_1.scala b/tests/neg-macros/tasty-macro-positions/quoted_1.scala index f70603b0e0ec..d63043f29a7c 100644 --- a/tests/neg-macros/tasty-macro-positions/quoted_1.scala +++ b/tests/neg-macros/tasty-macro-positions/quoted_1.scala @@ -8,7 +8,7 @@ object Macros { import quotes.reflect._ val pos = Term.of(x).underlyingArgument.pos report.error("here is the the argument is " + Term.of(x).underlyingArgument.show, pos) - report.error("here (+5) is the the argument is " + Term.of(x).underlyingArgument.show, pos.sourceFile, pos.start + 5, pos.end + 5) + report.error("here (+5) is the the argument is " + Term.of(x).underlyingArgument.show, Position(pos.sourceFile, pos.start + 5, pos.end + 5)) '{} }