Skip to content

Commit

Permalink
bugfix: Allow -release flag for Scala 3
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Aug 29, 2024
1 parent 7964e55 commit 3a9f370
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ case class ScalaPresentationCompiler(
val scalaVersion = BuildInfo.scalaCompilerVersion

private val forbiddenOptions = Set("-print-lines", "-print-tasty")
private val forbiddenDoubleOptions = Set("-release")
private val forbiddenDoubleOptions = Set.empty[String]
given ReportContext =
folderPath
.map(StdReportContext(_, _ => buildTargetName, reportsLevel))
Expand Down
71 changes: 71 additions & 0 deletions tests/cross/src/test/scala/tests/pc/Release11CompletionSuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package tests.pc

import tests.BaseCompletionSuite
import java.nio.file.Path

class Release11CompletionSuite extends BaseCompletionSuite {

override protected def ignoreScalaVersion: Option[IgnoreScalaVersion] = Some(
IgnoreScala211
)

override protected def scalacOptions(classpath: Seq[Path]): Seq[String] = Seq(
"-release",
"11"
)

check(
"keyword",
"""|object Main {
| "M".rep@@
|}
|""".stripMargin,
// repeat method was added in JDK 11
"""|repeat(x$1: Int): String
|replace(x$1: Char, x$2: Char): String
|replace(x$1: CharSequence, x$2: CharSequence): String
|replaceAll(x$1: String, x$2: String): String
|replaceFirst(x$1: String, x$2: String): String
|prepended(c: Char): String
|prepended[B >: Char](elem: B): IndexedSeq[B]
|prependedAll(prefix: String): String
|prependedAll[B >: Char](prefix: IterableOnce[B]): IndexedSeq[B]
|charStepper: IntStepper with Stepper.EfficientSplit
|corresponds[B](that: IterableOnce[B])(p: (Char, B) => Boolean): Boolean
|corresponds[B](that: Seq[B])(p: (Char, B) => Boolean): Boolean
|reduceLeftOption[B >: Char](op: (B, Char) => B): Option[B]
|reduceOption[B >: Char](op: (B, B) => B): Option[B]
|reduceRightOption[B >: Char](op: (Char, B) => B): Option[B]
|replaceAllLiterally(literal: String, replacement: String): String
|repr: WrappedString
|reverseMap[B](f: Char => B): IndexedSeq[B]
|""".stripMargin,
compat = Map(
"3" ->
"""|repeat(x$0: Int): String
|replace(x$0: CharSequence, x$1: CharSequence): String
|replace(x$0: Char, x$1: Char): String
|replaceAll(x$0: String, x$1: String): String
|replaceFirst(x$0: String, x$1: String): String
|replaceAllLiterally(literal: String, replacement: String): String
|repr: C
|""".stripMargin,
"2.12" ->
"""|repeat(x$1: Int): String
|replace(x$1: Char, x$2: Char): String
|replace(x$1: CharSequence, x$2: CharSequence): String
|replaceAll(x$1: String, x$2: String): String
|replaceFirst(x$1: String, x$2: String): String
|repr: String
|replaceAllLiterally(literal: String, replacement: String): String
|repr: WrappedString
|corresponds[B](that: GenSeq[B])(p: (Char, B) => Boolean): Boolean
|reduceLeftOption[B >: Char](op: (B, Char) => B): Option[B]
|reduceOption[A1 >: Char](op: (A1, A1) => A1): Option[A1]
|reduceRightOption[B >: Char](op: (Char, B) => B): Option[B]
|reverseMap[B, That](f: Char => B)(implicit bf: CanBuildFrom[String,B,That]): That
|""".stripMargin
)
)

}
67 changes: 67 additions & 0 deletions tests/cross/src/test/scala/tests/pc/Release8CompletionSuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package tests.pc

import tests.BaseCompletionSuite
import java.nio.file.Path

class Release8CompletionSuite extends BaseCompletionSuite {

override protected def ignoreScalaVersion: Option[IgnoreScalaVersion] = Some(
IgnoreScala211
)

override protected def scalacOptions(classpath: Seq[Path]): Seq[String] = Seq(
"-release",
"8"
)

check(
"keyword",
"""|object Main {
| "M".rep@@
|}
|""".stripMargin,
"""|replace(x$1: Char, x$2: Char): String
|replace(x$1: CharSequence, x$2: CharSequence): String
|replaceAll(x$1: String, x$2: String): String
|replaceFirst(x$1: String, x$2: String): String
|prepended(c: Char): String
|prepended[B >: Char](elem: B): IndexedSeq[B]
|prependedAll(prefix: String): String
|prependedAll[B >: Char](prefix: IterableOnce[B]): IndexedSeq[B]
|charStepper: IntStepper with Stepper.EfficientSplit
|corresponds[B](that: IterableOnce[B])(p: (Char, B) => Boolean): Boolean
|corresponds[B](that: Seq[B])(p: (Char, B) => Boolean): Boolean
|reduceLeftOption[B >: Char](op: (B, Char) => B): Option[B]
|reduceOption[B >: Char](op: (B, B) => B): Option[B]
|reduceRightOption[B >: Char](op: (Char, B) => B): Option[B]
|replaceAllLiterally(literal: String, replacement: String): String
|repr: WrappedString
|reverseMap[B](f: Char => B): IndexedSeq[B]
|""".stripMargin,
compat = Map(
"3" ->
"""|replace(x$0: CharSequence, x$1: CharSequence): String
|replace(x$0: Char, x$1: Char): String
|replaceAll(x$0: String, x$1: String): String
|replaceFirst(x$0: String, x$1: String): String
|replaceAllLiterally(literal: String, replacement: String): String
|repr: C
|""".stripMargin,
"2.12" ->
"""|replace(x$1: Char, x$2: Char): String
|replace(x$1: CharSequence, x$2: CharSequence): String
|replaceAll(x$1: String, x$2: String): String
|replaceFirst(x$1: String, x$2: String): String
|repr: String
|replaceAllLiterally(literal: String, replacement: String): String
|repr: WrappedString
|corresponds[B](that: GenSeq[B])(p: (Char, B) => Boolean): Boolean
|reduceLeftOption[B >: Char](op: (B, Char) => B): Option[B]
|reduceOption[A1 >: Char](op: (A1, A1) => A1): Option[A1]
|reduceRightOption[B >: Char](op: (Char, B) => B): Option[B]
|reverseMap[B, That](f: Char => B)(implicit bf: CanBuildFrom[String,B,That]): That
|""".stripMargin
)
)

}

0 comments on commit 3a9f370

Please sign in to comment.