8000 WiP Separate the scalalib from the Scala.js library. by sjrd · Pull Request #4787 · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content

WiP Separate the scalalib from the Scala.js library. #4787

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add a compiler option not to optimize Scala varargs as JS arrays.
We use it in the scalalib, so that we do not generate references
to `toScalaVarArgs`, which uses custom collections from the
Scala.js library.
  • Loading branch information
sjrd committed Oct 27, 2023
commit 2944d987b75bbfa25d25a3c409efe2735327531b
Original file line number Diff line number Diff line change
Expand Up @@ -5504,7 +5504,7 @@ abstract class GenJSCode[G <: Global with Singleton](val global: G)
* the extension to `false`.
*/
for ((arg, wasRepeated) <- args.zipAll(wereRepeated, EmptyTree, false)) yield {
if (wasRepeated) {
if (wasRepeated && !scalaJSOpts.avoidOptimizingScalaVarargsAsJSArray) {
tryGenRepeatedParamAsJSArray(arg, handleNil = false).fold {
genExpr(arg)
} { genArgs =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ trait ScalaJSOptions {
* If false, bad calls to classOf will cause an error. */
def fixClassOf: Boolean

/** Should we avoid optimizing Scala varargs as js.Array-based seqs?
*
* This is normally only used when compiling the scalalib.
*/
def avoidOptimizingScalaVarargsAsJSArray: Boolean

/** Should static forwarders be emitted for non-top-level objects.
*
* Scala/JVM does not do that. Since Scala.js 1.2.0, we do not do it by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class ScalaJSPlugin(val global: Global) extends NscPlugin {
object scalaJSOpts extends ScalaJSOptions {
import ScalaJSOptions.URIMap
var fixClassOf: Boolean = false
var avoidOptimizingScalaVarargsAsJSArray: Boolean = false
var genStaticForwardersForNonTopLevelObjects: Boolean = false
lazy val sourceURIMaps: List[URIMap] = {
if (_sourceURIMaps.nonEmpty)
Expand Down Expand Up @@ -109,6 +110,8 @@ class ScalaJSPlugin(val global: Global) extends NscPlugin {
for (option <- options) {
if (option == "fixClassOf") {
fixClassOf = true
} else if (option == "avoidOptimizingScalaVarargsAsJSArray") {
avoidOptimizingScalaVarargsAsJSArray = true
} else if (option == "genStaticForwardersForNonTopLevelObjects") {
genStaticForwardersForNonTopLevelObjects = true
} else if (option == "nowarnGlobalExecutionContext") {
Expand Down
12 changes: 7 additions & 5 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,8 @@ object Build {

// Tell the plugin to hack-fix bad classOf trees
scalacOptions ++= scalaJSCompilerOption("fixClassOf"),
// And not to optimize Scala varargs as js.Array-based seqs
scalacOptions ++= scalaJSCompilerOption("avoidOptimizingScalaVarargsAsJSArray"),

libraryDependencies +=
"org.scala-lang" % "scala-library" % scalaVersion.value classifier "sources",
Expand Down Expand Up @@ -1923,16 +1925,16 @@ object Build {
scalaVersion.value match {
case `default212Version` =>
Some(ExpectedSizes(
fastLink = 772000 to 773000,
fullLink = 145000 to 146000,
fastLinkGz = 91000 to 92000,
fastLink = 766000 to 767000,
fullLink = 144000 to 145000,
fastLinkGz = 90000 to 91000,
fullLinkGz = 35000 to 36000,
))

case `default213Version` =>
Some(ExpectedSizes(
fastLink = 480000 to 481000,
fullLink = 102000 to 103000,
fastLink = 482000 to 483000,
fullLink = 103000 to 104000,
fastLinkGz = 62000 to 63000,
fullLinkGz = 27000 to 28000,
))
Expand Down
0