Skip to content

Commit 8eaa582

Browse files
authored
Merge pull request #556 from sjrd/scalajs-1.7.1
Announcing Scala.js 1.7.1.
2 parents 29a1b41 + 0dc97cc commit 8eaa582

File tree

4 files changed

+139
-1
lines changed

4 files changed

+139
-1
lines changed

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ colors: #in hex code if not noted else
6464

6565
### VERSIONS ###
6666
versions:
67-
scalaJS: 1.7.0
67+
scalaJS: 1.7.1
6868
scalaJSBinary: 1
6969
scalaJS06x: 0.6.33
7070
scalaJS06xBinary: 0.6
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
layout: post
3+
title: Announcing Scala.js 1.7.1
4+
category: news
5+
tags: [releases]
6+
permalink: /news/2021-10-07/announcing-scalajs-1.7.1/
7+
---
8+
9+
10+
We are pleased to announce the release of Scala.js 1.7.1!
11+
12+
This is mostly a bugfix release.
13+
It also updates the version of the Scala standard library to 2.12.15 for 2.12.x versions.
14+
15+
Read on for more details.
16+
17+
<!--more-->
18+
19+
## Getting started
20+
21+
If you are new to Scala.js, head over to [the tutorial]({{ BASE_PATH }}/tutorial/).
22+
23+
If you need help with anything related to Scala.js, you may find our community [on Gitter](https://gitter.im/scala-js/scala-js) and [on Stack Overflow](https://stackoverflow.com/questions/tagged/scala.js).
24+
25+
Bug reports can be filed [on GitHub](https://github.com/scala-js/scala-js/issues).
26+
27+
## Release notes
28+
29+
If upgrading from Scala.js 0.6.x, make sure to read [the release notes of Scala.js 1.0.0]({{ BASE_PATH }}/news/2020/02/25/announcing-scalajs-1.0.0/) first, as they contain a host of important information, including breaking changes.
30+
31+
This is a **patch** release:
32+
33+
* It is backward binary compatible with all earlier versions in the 1.x series: libraries compiled with 1.0.x through 1.7.0 can be used with 1.7.1 without change.
34+
* It is forward binary compatible with 1.7.0: libraries compiled with 1.7.1 can be used with 1.7.0 without change.
35+
* It is backward source compatible with 1.7.0: source code that used to compile with 1.7.0 should compile as is when upgrading to 1.7.1.
36+
37+
In addition, like Scala.js 1.7.0:
38+
39+
* It is *not* forward binary compatible with 1.6.x: libraries compiled with 1.7.1 cannot be used with 1.6.x or earlier.
40+
* It is *not* entirely backward source compatible with 1.6.x: it is not guaranteed that a codebase will compile *as is* when upgrading from 1.6.x or earlier (in particular in the presence of `-Xfatal-warnings`).
41+
42+
As a reminder, libraries compiled with 0.6.x cannot be used with Scala.js 1.x; they must be republished with 1.x first.
43+
44+
## Fixes with compatibility concerns
45+
46+
### Default parameter values of `@js.native def`s are now ignored
47+
48+
#### Context
49+
50+
In native JS types, default parameters of methods are only meaningful by their *presence*, but not by their actual *values*.
51+
When calling a method without specifying one of its default parameters, the parameter is actually omitted in JavaScript, and therefore it is up to the called method to fill in its own default behavior.
52+
This notably allows to use the pseudo-value `= js.native`.
53+
For example:
54+
55+
{% highlight scala %}
56+
@js.native @JSGlobal
57+
object Foo extends js.Object {
58+
def bar(x: Int, y: Int = js.native): Int = js.native
59+
}
60+
{% endhighlight %}
61+
62+
could be an accurate description of the following JavaScript definition:
63+
64+
{% highlight javascript %}
65+
const Foo = {
66+
bar(x, y) {
67+
return x + (y === undefined ? 1 : y);
68+
}
69+
};
70+
{% endhighlight %}
71+
72+
When calling that method from Scala.js as
73+
74+
{% highlight scala %}
75+
println(Foo.bar(5))
76+
{% endhighlight %}
77+
78+
it is translated as `Foo.bar(5)`, without second parameter, and it is therefore the JavaScript condition on `y === undefined` that is used.
79+
80+
This behavior applies regardless of the value used in the facade.
81+
If we pretend in the facade that the default value is `2`, as follows:
82+
83+
{% highlight scala %}
84+
def bar(x: Int, y: Int = 2): Int = js.native
85+
{% endhighlight %}
86+
87+
it will have no impact on the behavior of the code.
88+
The parameter will still be omitted when calling the JavaScript function, which will still use `1` as the actual default value.
89+
90+
#### Issue in previous versions
91+
92+
The above behavior has always been specified as is.
93+
It was however previously incorrectly implemented for `@js.native def`s.
94+
For example, if `bar` was a top-level function, we could have defined is as
95+
96+
{% highlight scala %}
97+
object Foo {
98+
@js.native @JSGlobal("bar")
99+
def bar(x: Int, y: Int = 2): Int = js.native
100+
}
101+
{% endhighlight %}
102+
103+
In that case, until Scala.js 1.7.0, calling `Foo.bar(5)` was erroneously compiled to `bar(5, 2)`.
104+
This is inconsistent with other native JS methods.
105+
106+
That also prevented such definitions to use `= js.native`, since it would report that `js.native` cannot be compiled to actual code for run-time execution.
107+
108+
#### Fix in Scala.js 1.7.1
109+
110+
In Scala.js 1.7.1, the behavior of default parameters in `@js.native def`s has been aligned with other native JS methods.
111+
Now, the call `Foo.bar(5)` is correctly compiled to `bar(5)`, and therefore uses the JS-defined default value of `1`.
112+
113+
**This change may break some code** when compiling the call site `bar(5)` with Scala.js 1.7.1, if the code relied on the buggy previous behavior.
114+
That may only happen if the default value specified in the facade type is not an accurate representation of what the JavaScript code actually uses.
115+
116+
The fix also allows `= js.native` to be used in the default parameters of `@js.native def`s.
117+
118+
## Bug fixes
119+
120+
Among others, the following bugs have been fixed in 1.7.1:
121+
122+
* [#4542](https://github.com/scala-js/scala-js/issues/4542) Many `dynamicImports` with `FewestModules` causes the Linker to GC itself to death
123+
* [#4545](https://github.com/scala-js/scala-js/issues/4545) JDK 12+ bug: Referring to non-existent class `java.lang.constant.ConstantDesc`
124+
* [#4548](https://github.com/scala-js/scala-js/issues/4548) Referencing only the class data of an imported native JS class causes a GCC error
125+
* [#4553](https://github.com/scala-js/scala-js/issues/4553) `js.native` as default arg doesn't compile for top-level method facades
126+
* [#4554](https://github.com/scala-js/scala-js/issues/4554) Default values for params of `@js.native def`s are actually used, instead of being replaced by `<UndefinedParam>`
127+
128+
You can find the full list [on GitHub](https://github.com/scala-js/scala-js/issues?q=is%3Aissue+milestone%3Av1.7.1+is%3Aclosed).

doc/all-api.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ title: All previous versions of the Scala.js API
55

66
## All previous versions of the API
77

8+
### Scala.js 1.7.1
9+
* [1.7.1 scalajs-library]({{ site.production_url }}/api/scalajs-library/1.7.1/scala/scalajs/js/index.html)
10+
* [1.7.1 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/1.7.1/)
11+
* [1.7.1 scalajs-ir]({{ site.production_url }}/api/scalajs-ir/1.7.1/org/scalajs/ir/index.html)
12+
* [1.7.1 scalajs-linker-interface]({{ site.production_url }}/api/scalajs-linker-interface/1.7.1/org/scalajs/linker/interface/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-interface-js/1.7.1/org/scalajs/linker/interface/index.html))
13+
* [1.7.1 scalajs-linker]({{ site.production_url }}/api/scalajs-linker/1.7.1/org/scalajs/linker/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-js/1.7.1/org/scalajs/linker/index.html))
14+
* [1.7.1 scalajs-test-adapter]({{ site.production_url }}/api/scalajs-sbt-test-adapter/1.7.1/org/scalajs/testing/adapter/index.html)
15+
* [1.7.1 sbt-scalajs]({{ site.production_url }}/api/sbt-scalajs/1.7.1/#org.scalajs.sbtplugin.package)
16+
817
### Scala.js 1.7.0
918
* [1.7.0 scalajs-library]({{ site.production_url }}/api/scalajs-library/1.7.0/scala/scalajs/js/index.html)
1019
* [1.7.0 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/1.7.0/)

doc/internals/version-history.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Version history
55

66
## Version history of Scala.js
77

8+
- [1.7.1](/news/2021/10/07/announcing-scalajs-1.7.1/)
89
- [1.7.0](/news/2021/08/04/announcing-scalajs-1.7.0/)
910
- [1.6.0](/news/2021/06/09/announcing-scalajs-1.6.0/)
1011
- [1.5.1](/news/2021/04/01/announcing-scalajs-1.5.1/)

0 commit comments

Comments
 (0)