Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove -release option from the Scala 3 PC #3812

Merged
merged 1 commit into from
Apr 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ case class ScalaPresentationCompiler(
val scalaVersion = BuildInfo.scalaCompilerVersion

private val forbiddenOptions = Set("-print-lines", "-print-tasty")
private val forbiddenDoubleOptions = Set("-release")

val compilerAccess: CompilerAccess[StoreReporter, InteractiveDriver] =
Scala3CompilerAccess(
config,
Expand All @@ -58,10 +60,19 @@ case class ScalaPresentationCompiler(
using ec
)

private def removeDoubleOptions(options: List[String]): List[String] =
options match
case head :: _ :: tail if forbiddenDoubleOptions(head) =>
removeDoubleOptions(tail)
case head :: tail => head :: removeDoubleOptions(tail)
case Nil => options
Comment on lines +63 to +68
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not

Suggested change
private def removeDoubleOptions(options: List[String]): List[String] =
options match
case head :: _ :: tail if forbiddenDoubleOptions(head) =>
removeDoubleOptions(tail)
case head :: tail => head :: removeDoubleOptions(tail)
case Nil => options
options.filterNot(forbiddenDoubleOptions)

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, nevermind, removeDoubleOptions transforms List("-release", "8", ...) to List(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to get a bit more creative here 😅


def newDriver: InteractiveDriver =
val implicitSuggestionTimeout = List("-Ximport-suggestion-timeout", "0")
val defaultFlags = List("-color:never")
val filteredOptions = options.filterNot(forbiddenOptions)
val filteredOptions = removeDoubleOptions(
options.filterNot(forbiddenOptions)
)
val settings =
filteredOptions ::: defaultFlags ::: implicitSuggestionTimeout ::: "-classpath" :: classpath
.mkString(
Expand Down