pjrt/stags

Compilation fails (GraalVM 21.3.0 Java 11 on Ubuntu 21.10)

Opened this issue · 0 comments

bdina commented

i'm working with:

Author: Pedro Rodriguez <pedro@pjrt.co>
Date:   Mon Mar 15 17:52:54 2021 -0400

    Change the local tutorial

trying to build using GraalVM 21.3.0 Java 11 on Ubuntu 21.10 fails with the errors:

[info]   Compilation completed in 11.585s.
[error] /git/stags/stags/src/main/scala/co/pjrt/stags/TagGenerator.scala:310:41: value toList is not a member of java.util.stream.Stream[String]
[error]     val line = tree.tokens.syntax.lines.toList(lineWithTagName).trim
[error]                                         ^
[error] /git/stags/stags/src/main/scala/co/pjrt/stags/TagGenerator.scala:309:49: local val lineWithTagName in method addrForTree is never used
[error]     val lineWithTagName = tagName.pos.startLine - tree.pos.startLine
[error]                                                 ^
[error] /git/stags/stags/src/main/scala/co/pjrt/stags/TagGenerator.scala:310:9: local val line in method addrForTree is never used
[error]     val line = tree.tokens.syntax.lines.toList(lineWithTagName).trim
[error]         ^
[error] three errors found
[error] (stags / Compile / compileIncremental) Compilation failed
[error] Total time: 17 s, completed Nov 24, 2021, 6:48:15 PM

i've made a small tweak to the code and am able to get it building, though i don't yet know whether the resulting program actually works as it's supposed to. here's that diff:

diff --git a/stags/src/main/scala/co/pjrt/stags/TagGenerator.scala b/stags/src/main/scala/co/pjrt/stags/TagGenerator.scala
index 5468436..559c530 100644
--- a/stags/src/main/scala/co/pjrt/stags/TagGenerator.scala
+++ b/stags/src/main/scala/co/pjrt/stags/TagGenerator.scala
@@ -303,11 +303,12 @@ private object AddressGen {
    * cursor location.
    */
   def addrForTree(tree: Tree, tagName: Name): String = {
+    import scala.collection.JavaConverters._

     // DESNOTE(2017-12-21, pjrt): This should always return 0 or more, otherwise
     // scalameta wouldn't have parsed it.
     val lineWithTagName = tagName.pos.startLine - tree.pos.startLine
-    val line = tree.tokens.syntax.lines.toList(lineWithTagName).trim
+    val line = tree.tokens.syntax.lines.iterator.asScala.toList(lineWithTagName).trim

     val name = tagName.value
     val replacement = s"\\\\zs$name"