File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed
scala-3/play/twirl/compiler/test
scala/play/twirl/compiler/test Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ lazy val compiler = project
112112 }
113113 },
114114 libraryDependencies += parserCombinators(scalaVersion.value),
115- libraryDependencies += " org.scalameta" %% " parsers" % " 4.13.10 " ,
115+ libraryDependencies += " org.scalameta" %% " parsers" % " 4.14.2 " ,
116116 run / fork := true ,
117117 buildInfoKeys := Seq [BuildInfoKey ](scalaVersion),
118118 buildInfoPackage := " play.twirl.compiler" ,
Original file line number Diff line number Diff line change @@ -92,7 +92,12 @@ object Helper {
9292 val reporter = driver.compile()
9393
9494 if (reporter.hasErrors) {
95- val error = reporter.allErrors.sortBy(_.pos.point).head
95+ val errorsSortedAll = reporter.allErrors.sortBy(_.pos.point)
96+ val errorsSortedWithoutZeroPos =
97+ errorsSortedAll.filterNot(e => mapper.mapLine(e.pos.line + 1 ) == 0 && mapper.mapPosition(e.pos.point) == 0 )
98+ // We filter out any errors that are mapped to line 0 and column 0, because since Scalameta 4.14.1 it's likely
99+ // those are very general errors. However, fall back to all errors in case after filtering no errors are left.
100+ val error = (if (errorsSortedWithoutZeroPos.isEmpty) errorsSortedAll else errorsSortedWithoutZeroPos).head
96101 val message = error.msg
97102 val pos = error.pos
98103 throw CompilationError (message.toString, mapper.mapLine(pos.line + 1 ), mapper.mapPosition(pos.point))
Original file line number Diff line number Diff line change @@ -200,20 +200,23 @@ class CompilerSpec extends AnyWordSpec with Matchers {
200200 }
201201
202202 " fail compilation for error.scala.html" in {
203+ val msg = if (BuildInfo .scalaVersion.startsWith(" 3." )) " Not found: world" else " not found: value world"
203204 val helper = newCompilerHelper
204205 the[CompilationError ] thrownBy helper.compile[(() => Html )](" error.scala.html" , " html.error" ) must have(
205206 Symbol (" line" )(5 ),
206- // Symbol("column ")(12) TODO: need fix https://github.com/playframework/twirl/issues/571 to back
207+ Symbol (" message " )(msg),
207208 Symbol (" column" )(463 )
208209 )
209210 }
210211
211212 " fail compilation for errorInTemplateArgs.scala.html" in {
212213 val helper = newCompilerHelper
214+ val msg =
215+ if (BuildInfo .scalaVersion.startsWith(" 3." )) " ':' expected, but ')' found" else " ':' expected but ')' found."
213216 the[CompilationError ] thrownBy helper
214217 .compile[(() => Html )](" errorInTemplateArgs.scala.html" , " html.errorInTemplateArgs" ) must have(
215218 Symbol (" line" )(5 ),
216- // Symbol("column ")(6) TODO: need fix https://github.com/playframework/twirl/issues/571 to back
219+ Symbol (" message " )(msg),
217220 Symbol (" column" )(458 )
218221 )
219222 }
You can’t perform that action at this time.
0 commit comments