Skip to content

Commit 1d8fadd

Browse files
committed
Note changes in unicode escapes and case companion
1 parent e89910c commit 1d8fadd

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

_overviews/FAQ/index.md

+8
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ REPL, but won't work in typical Scala 3 application code.
139139
For an alternative way to detect the Scala 3 version, see
140140
[this gist](https://gist.github.com/romanowski/de14691cab7340134e197419bc48919a).
141141

142+
### I want to use Scala 3 but now a bunch of stuff just broke in my project. What's up with that?
143+
144+
There is a [guide for migration](https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html)
145+
that includes a [table of incompatibilities](https://docs.scala-lang.org/scala3/guides/migration/incompatibility-table.html).
146+
Incompatibilities are largely due to dropping old features and introducing new ones,
147+
rather than subtle changes in existing features.
148+
The migration guide provides strategies for either migrating to new syntax or maintaining cross-compatibility.
149+
142150
### Why is my (abstract or overridden) `val` null?
143151

144152
<!-- this is left over from a previous version of the FAQ.

_overviews/scala3-migration/incompat-other-changes.md

+28-1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,33 @@ fooCtr.tupled((2, false))
166166
~~~
167167
{% endtab %}
168168
{% endtabs %}
169+
170+
To assist migration, the compiler will insert the call to `apply` as needed:
171+
{% tabs scala-3-companion_3 %}
172+
{% tab 'Scala 3 Only' %}
173+
~~~ scala
174+
case class C(i: Int)
175+
List(42).map(C)
176+
case class D(i: Int, j: Int)
177+
List(42->27).map(D)
178+
~~~
179+
{% endtab %}
180+
{% endtabs %}
181+
182+
In Scala 2.13.13, this behavior is enabled under `-Xsource:3cross`.
183+
That is, case companions that do not extend `Function` can be used as if they did,
184+
or equivalently, as though `apply` were inserted. However, since Scala 2 does not
185+
adapt `apply` for the tupled case, `tupled` is supported directly.
186+
{% tabs scala-3-companion_4 %}
187+
{% tab 'Scala 2 Only' %}
188+
~~~ scala
189+
case class C(i: Int); object C
190+
List(42).map(C)
191+
case class D(i: Int, j: Int); object D
192+
List(42->27).map(D.tupled)
193+
~~~
194+
{% endtab %}
195+
{% endtabs %}
169196
## Explicit Call to `unapply`
170197

171198
In Scala, case classes have an auto-generated extractor method, called `unapply` in their companion object.
@@ -325,4 +352,4 @@ In such case, we can use a wrapper class around `Foo`:
325352

326353
-def g(foos: Seq[Foo[_]]): Unit
327354
+def g(foos: Seq[FooWrapper[_]]): Unit
328-
{% endhighlight %}
355+
{% endhighlight %}

_overviews/scala3-migration/incompat-syntactic.md

+11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ It is worth noting that most of the changes can be automatically handled during
2323
|[Wrong indentation](#wrong-indentation)||||
2424
|[`_` as a type parameter](#_-as-a-type-parameter)||||
2525
|[`+` and `-` as type parameters](#-and---as-type-parameters)||||
26+
|[Unicode escapes](incompat-syntactic.html#unicode-escapes)||||
2627

2728
## Restricted Keywords
2829

@@ -237,3 +238,13 @@ The solution is to choose another valid identifier, for instance `T`.
237238

238239
However, `+` and `-` still are valid type identifiers in general.
239240
You can write `type +`.
241+
242+
## Unicode escapes
243+
244+
Unicode escapes of the form `\u0061` are no longer natively supported in any position by the compiler.
245+
246+
Instead, they processed like other escapes in string literals.
247+
This means, in particular, that they are not processed in "triple-quoted" strings or by the `raw` interpolator.
248+
249+
In Scala 2, a deprecation is issued, but under `-Xsource:3cross`, the behavior is the same as Scala 3.
250+

_overviews/scala3-migration/incompatibility-table.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Some of the old syntax is not supported anymore.
4242
|[Wrong indentation](incompat-syntactic.html#wrong-indentation)||||
4343
|[`_` as a type parameter](incompat-syntactic.html#_-as-a-type-parameter)||||
4444
|[`+` and `-` as type parameters](incompat-syntactic.html#-and---as-type-parameters)||||
45+
|[Unicode escapes](incompat-syntactic.html#unicode-escapes)||||
4546

4647
### Dropped Features
4748

0 commit comments

Comments
 (0)