|
| 1 | +--- |
| 2 | +layout: blog-page |
| 3 | +title: Scala 3.0.0-RC1 – first release candidate is here |
| 4 | +author: Anatolii Kmetiuk |
| 5 | +authorImg: /images/anatolii.png |
| 6 | +date: 2020-02-17 |
| 7 | +--- |
| 8 | + |
| 9 | +Greetings from the Scala 3 team! We are delighted to announce the first release candidate of the stable version of Scala 3 – Scala 3.0.0-RC1. |
| 10 | + |
| 11 | +This release brings some last-minute polishings, clean-ups and changes before the big release. There were a few language changes to improve the user experience, as well as the polishings of the metaprogramming framework. We have also worked on the issues that had to be fixed before the stable release. |
| 12 | + |
| 13 | +Overall, more than [400 PRs](https://github.com/lampepfl/dotty/pulls?q=is%3Apr+is%3Aclosed+closed%3A%3E2020-12-02+sort%3Acomments-desc) were merged after the M3 release and until today! Read more below! |
| 14 | + |
| 15 | +<!--more--> |
| 16 | +# Allow secondary type parameter list in extension methods |
| 17 | +Type parameters on extensions can now be combined with type parameters on the methods themselves. E.g.: |
| 18 | + |
| 19 | +```scala |
| 20 | +List(1, 2, 3).second[Int] |
| 21 | +extension [A](xs: List[A]) |
| 22 | + def sumBy[B](f: A => B)(using Numeric[B]): B = ... |
| 23 | +``` |
| 24 | + |
| 25 | +Type arguments matching method type parameters are passed as usual: |
| 26 | + |
| 27 | +```scala |
| 28 | +List("a", "bb", "ccc").sumBy[Int](_.length) |
| 29 | +``` |
| 30 | +By contrast, type arguments matching type parameters following `extension` can be passed |
| 31 | +only if the method is referenced as a non-extension method: |
| 32 | + |
| 33 | +```scala |
| 34 | +sumBy[String](List("a", "bb", "ccc"))(_.length) |
| 35 | +``` |
| 36 | + |
| 37 | +Or, when passing both type arguments: |
| 38 | + |
| 39 | +```scala |
| 40 | +sumBy[String](List("a", "bb", "ccc"))[Int](_.length) |
| 41 | +``` |
| 42 | + |
| 43 | +For discussion, see [PR #10940](https://github.com/lampepfl/dotty/pull/10940). For more information about the extension methods, see [documentation](https://dotty.epfl.ch/docs/reference/contextual/extension-methods.html). |
| 44 | + |
| 45 | +# New `import` syntax |
| 46 | +The following are the changes to the `import` syntax made in this release. |
| 47 | + |
| 48 | +Wildcard import `_` is replaced by `*`. The motivation is that the majority of other languages use `*`. For example: |
| 49 | + |
| 50 | +```scala |
| 51 | +import scala.annotation.* // imports everything in the annotation package |
| 52 | +``` |
| 53 | + |
| 54 | +Renaming operator `=>` is replaced by a soft keyword `as`. `as` is also allowed outside braces. For example: |
| 55 | + |
| 56 | +```scala |
| 57 | +import scala.collection.mutable as mut |
| 58 | +import NumPy as np |
| 59 | +``` |
| 60 | + |
| 61 | +For the details and discussion, see [PR #11244](https://github.com/lampepfl/dotty/pull/11244). Read more about this change in the [documentation](https://dotty.epfl.ch/docs/reference/changed-features/imports.html). |
| 62 | + |
| 63 | +# Use `*` for vararg splices. |
| 64 | +[PR #11240](https://github.com/lampepfl/dotty/pull/11240) changed the syntax of vararg splices in patterns and function arguments. The new syntax uses a postfix `*`, instead of `: _*`, analogously to how a vararg parameter is declared. |
| 65 | + |
| 66 | +# Use `uninitialized` for wildcard initializers |
| 67 | +An obscure use of `_` occurs in var definitions: |
| 68 | + |
| 69 | +```scala |
| 70 | +var x: T = _ |
| 71 | +``` |
| 72 | + |
| 73 | +It defines a concrete variable x without an initial value, or rather the default initial value that the JVM assigns to object fields. It can only be used in a class or object, not to initialize a local variable. |
| 74 | + |
| 75 | +We came up with an arguably better way to express this idiom: the special `uninitialized` value in the `scala.compiletime` object. To get an uninitialized field, you now write: |
| 76 | + |
| 77 | +```scala |
| 78 | +import scala.compiletime.uninitialized |
| 79 | + |
| 80 | +var x: A = uninitialized |
| 81 | +``` |
| 82 | + |
| 83 | +This way expresses the intent of the idiom in a more verbose and easy to read way than simply writing an underscore. |
| 84 | + |
| 85 | +For discussion, see [PR #11231](https://github.com/lampepfl/dotty/pull/11231), and the [documentation](https://dotty.epfl.ch/docs/reference/dropped-features/wildcard-init.html) is available on our website. |
| 86 | + |
| 87 | +# Eta-expand companion object if functions are expected |
| 88 | +Starting from RC1, we no longer generate a function parent for companions of case classes. Which means, for example, that given `case class Foo(x: Int)`, you won't be able to use `Foo` in a position where a function is expected: |
| 89 | + |
| 90 | +```scala |
| 91 | +case class Foo(x: Int) |
| 92 | +def f(g: Int => Foo) = g(10) |
| 93 | + |
| 94 | +f(Foo) |
| 95 | +``` |
| 96 | + |
| 97 | +Results in: |
| 98 | + |
| 99 | +```scala |
| 100 | +1 |f(Foo) |
| 101 | + | ^^^ |
| 102 | + |The method `apply` is inserted. The auto insertion will be deprecated, please write `Foo.apply` explicitly. |
| 103 | +``` |
| 104 | + |
| 105 | +As the warning suggests, now you should write `Foo.apply` instead of `Foo`. See [Issue #6190](https://github.com/lampepfl/dotty/issues/6190) and [PR #7207](https://github.com/lampepfl/dotty/pull/7207) for discussion. |
| 106 | + |
| 107 | +# Settling on `scaladoc` as the documentation tool |
| 108 | +We have settled on using the well-known `scaladoc` as a name for the documentation tool for Scala 3 (known previously as `scala3doc`).. The obsolete `dotty-doc` (or `scala3-doc`) is removed in RC1. We have also removed all the Kotlin dependencies (Dokka, etc.) from scaladoc. For details, see [PR #11349](https://github.com/lampepfl/dotty/pull/11349). To read more about `scaladoc`, see [documentation](https://dotty.epfl.ch/docs/usage/scaladoc/index.html) |
| 109 | + |
| 110 | +# Use `future` and `future-migration` to specify language versions after 3.0 in `-source` |
| 111 | +[PR #11355](https://github.com/lampepfl/dotty/pull/11355) changes the `-source` specifier for the Scala version(s) after 3.0 from `3.1` to `future`. I.e. it is now |
| 112 | +`-source future` and `-source future-migration` instead of `-source 3.1` and `-source 3.1-migration`. Language imports are changed analogously. The reason for the change is that we want to keep the possibility open to ship a `3.1` version that does not yet contain all the changes enabled under `-source future`. |
| 113 | + |
| 114 | +# Other language changes |
| 115 | +- Warn when matching against an opaque type [#10664](https://github.com/lampepfl/dotty/pull/10664) |
| 116 | +- Fix [#8634](https://github.com/lampepfl/dotty/issues/8634): Support -release option [#10746](https://github.com/lampepfl/dotty/pull/10746) – the same way Scala 2 does. This setting allows you to specify a version of the Java platform (8, 9 etc) and compile the code with classes specific to the that Java platform, and emit the bytecode for that version. |
| 117 | + |
| 118 | +# Metaprogramming changes |
| 119 | +A lot of work has been done on the metaprogramming side of things. Mostly we are cleaning up and polishing the API to prepare it for the stable release. The following are the important metaprogramming changes that took place: |
| 120 | + |
| 121 | +- Add `scala.quoted.Expr.unapply` as dual of `Expr.apply` [#10580](https://github.com/lampepfl/dotty/pull/10580) |
| 122 | +- Remove `Expr.StringContext.unapply` [#10675](https://github.com/lampepfl/dotty/pull/10675) |
| 123 | +- Add reflect `MatchCase` `TypeRepr` [#10735](https://github.com/lampepfl/dotty/pull/10735) |
| 124 | +- Rename `scala.quoted.staging.{Toolbox => Compiler}` [#11129](https://github.com/lampepfl/dotty/pull/11129) |
| 125 | +- Fix [#10863](https://github.com/lampepfl/dotty/issues/10863): Make show `AnyKind`ed [#10988](https://github.com/lampepfl/dotty/pull/10988) |
| 126 | +- Add ParamClause to allow multiple type param clauses [#11074](https://github.com/lampepfl/dotty/pull/11074) |
| 127 | +- Rework reflect Symbol fields API [#10705](https://github.com/lampepfl/dotty/pull/10705) |
| 128 | +- Rename `Liftable` to `ToExpr` and `Unliftable` to `FromExpr` [#10618](https://github.com/lampepfl/dotty/pull/10618) |
| 129 | +- Expand non-transparent macros after Typer [#9984](https://github.com/lampepfl/dotty/pull/9984) |
| 130 | +- Rework TastyInspector API to allow inspection of all files [#10792](https://github.com/lampepfl/dotty/pull/10792) |
| 131 | +- Allow leading context parameters in extension methods [#10940](https://github.com/lampepfl/dotty/pull/10940) |
| 132 | +- Rename `Not` to `NotGiven` to make its purpose clearer [#10720](https://github.com/lampepfl/dotty/pull/10720) |
| 133 | +- Fix [#10709](https://github.com/lampepfl/dotty/issues/10709): Add missing level check before inlining [#10781](https://github.com/lampepfl/dotty/pull/10781) |
| 134 | + |
| 135 | +# Let us know what you think! |
| 136 | +If you have questions or any sort of feedback, feel free to send us a message on our |
| 137 | +[Gitter channel](https://gitter.im/lampepfl/dotty). If you encounter a bug, please |
| 138 | +[open an issue on GitHub](https://github.com/lampepfl/dotty/issues/new). |
| 139 | + |
| 140 | + |
| 141 | +## Contributors |
| 142 | +Thank you to all the contributors who made this release possible 🎉 |
| 143 | + |
| 144 | +According to `git shortlog -sn --no-merges 3.0.0-M3..3.0.0-RC1` these are: |
| 145 | + |
| 146 | +``` |
| 147 | + 183 Martin Odersky |
| 148 | + 138 Nicolas Stucki |
| 149 | + 36 Krzysztof Romanowski |
| 150 | + 25 Filip Zybała |
| 151 | + 25 Liu Fengyun |
| 152 | + 24 Lan, Jian |
| 153 | + 22 Jamie Thompson |
| 154 | + 19 Tom Grigg |
| 155 | + 17 Andrzej Ratajczak |
| 156 | + 16 Stéphane Micheloud |
| 157 | + 15 Guillaume Martres |
| 158 | + 11 Paweł Marks |
| 159 | + 9 Phil |
| 160 | + 6 Aleksander Boruch-Gruszecki |
| 161 | + 6 Jonathan Brachthäuser |
| 162 | + 6 Natsu Kagami |
| 163 | + 6 odersky |
| 164 | + 4 Jasper Moeys |
| 165 | + 4 Adrien Piquerez |
| 166 | + 3 Sébastien Doeraene |
| 167 | + 3 Michał Pałka |
| 168 | + 3 Albert Chen |
| 169 | + 2 Alexandre Archambault |
| 170 | + 2 Som Snytt |
| 171 | + 2 kenji yoshida |
| 172 | + 2 Luc Henninger |
| 173 | + 2 Ayush |
| 174 | + 2 Raphael Jolly |
| 175 | + 2 Anatolii Kmetiuk |
| 176 | + 2 Olivier Blanvillain |
| 177 | + 2 changvvb |
| 178 | + 1 ysthakur |
| 179 | + 1 Ang Hao Yang |
| 180 | + 1 Ang9876 |
| 181 | + 1 AngAng |
| 182 | + 1 August Nagro |
| 183 | + 1 Ciara O'Brien |
| 184 | + 1 Dale Wijnand |
| 185 | + 1 Florian Cassayre |
| 186 | + 1 Florian Schmaus |
| 187 | + 1 Iltotore |
| 188 | + 1 Jason Zaugg |
| 189 | + 1 Julien Richard-Foy |
| 190 | + 1 Katrix |
| 191 | + 1 Master-Killer |
| 192 | + 1 Michael Pilquist |
| 193 | + 1 Mikael Blomstrand |
| 194 | + 1 Mike Samuel |
| 195 | + 1 Philippus |
| 196 | + 1 Philippus Baalman |
| 197 | + 1 Rick M |
| 198 | + 1 Stephane MICHELOUD |
| 199 | + 1 Timur Abishev |
| 200 | + 1 Tomas |
| 201 | + 1 ansvonwa |
| 202 | + 1 ayush |
| 203 | + 1 costa100 |
| 204 | + 1 iroha168 |
| 205 | + 1 noti0na1 |
| 206 | + 1 riiswa |
| 207 | + 1 tanishiking |
| 208 | +``` |
| 209 | + |
| 210 | +If you want to get your hands dirty and contribute to Scala 3, now is a good time to get involved! |
| 211 | +Head to our [Getting Started page for new contributors](https://dotty.epfl.ch/docs/contributing/getting-started.html), |
| 212 | +and have a look at some of the [good first issues](https://github.com/lampepfl/dotty/issues?q=is%3Aissue+is%3Aopen+label%3Aexp%3Anovice). |
| 213 | +They make perfect entry points into hacking on the compiler. |
| 214 | + |
| 215 | +We are looking forward to having you join the team of contributors. |
| 216 | + |
| 217 | +[Scastie]: https://scastie.scala-lang.org/?target=dotty |
| 218 | + |
| 219 | +[@odersky]: https://github.com/odersky |
| 220 | +[@DarkDimius]: https://github.com/DarkDimius |
| 221 | +[@smarter]: https://github.com/smarter |
| 222 | +[@felixmulder]: https://github.com/felixmulder |
| 223 | +[@nicolasstucki]: https://github.com/nicolasstucki |
| 224 | +[@liufengyun]: https://github.com/liufengyun |
| 225 | +[@OlivierBlanvillain]: https://github.com/OlivierBlanvillain |
| 226 | +[@biboudis]: https://github.com/biboudis |
| 227 | +[@allanrenucci]: https://github.com/allanrenucci |
| 228 | +[@Blaisorblade]: https://github.com/Blaisorblade |
| 229 | +[@Duhemm]: https://github.com/Duhemm |
| 230 | +[@AleksanderBG]: https://github.com/AleksanderBG |
| 231 | +[@milessabin]: https://github.com/milessabin |
| 232 | +[@anatoliykmetyuk]: https://github.com/anatoliykmetyuk |
0 commit comments