Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit e3e2cec

Browse files
authored
Auto pull scalafmt config bump scala2 version update exercise 1 (#125)
* Auto pull scalafmt config bump scala2 version * Update instructions for the first Scala 3 exercise
1 parent 761a635 commit e3e2cec

File tree

4 files changed

+39
-39
lines changed

4 files changed

+39
-39
lines changed

course-management.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ cmt {
1111
# List of folders containing test code
1212
test-code-folders = [
1313
"src/test"
14+
".scalafmt.conf"
1415
]
1516

1617
# List of README files

exercises/exercise_000_sudoku_solver_initial_state/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ Hit RETURN to stop solver
145145
in place in this project. scalafmt supports both Scala 2 and Scala 3. You can
146146
[re]format the code by running `scalafmtAll` from the sbt prompt. As we switch from
147147
Scala 2 to Scala 3, you need to make sure that a matching scalafmt configuration is
148-
in place. In any of the exercises, you can run `cmtc pull-template .scalafmt.conf`
149-
to "pull-in" the correct configuration file.
148+
in place.
150149

151150
### Markdown viewer in IntelliJ IDEA
152151

exercises/exercise_000_sudoku_solver_initial_state/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Global / onChangedBuildSource := ReloadOnSourceChanges
22

33
lazy val `moving-from-scala-2-to-scala-3` =
44
(project in file(".")).settings(
5-
scalaVersion := "2.13.10",
5+
scalaVersion := "2.13.11",
66
Compile / scalacOptions ++= CompileOptions.compileOptions,
77
libraryDependencies ++= Dependencies.dependencies,
88
testFrameworks += new TestFramework("munit.Framework"))

exercises/exercise_001_dotty_deprecated_syntax_rewriting/README.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,35 @@ up on the [scala-lang](https://www.scala-lang.org) website. As an alternative, w
1818
[`cs`](https://github.com/coursier/coursier) (Coursier) to look up the information. Here's how to do it with `cs`:
1919

2020
```bash
21-
$ cs complete-dep org.scala-lang:scala3-compiler_3:
21+
$ cs complete-dep org.scala-lang:scala3-compiler_3: | grep -v RC
2222
3.0.0
23-
3.0.1-RC1
24-
3.0.1-RC1-bin-20210413-f3c1468-NIGHTLY
25-
3.0.1-RC1-bin-20210415-59ea58e-NIGHTLY
26-
3.0.1-RC1-bin-20210416-8086e4b-NIGHTLY
27-
.
28-
.
29-
.
23+
3.0.1
24+
3.0.2
25+
3.1.0
26+
3.1.1
27+
3.1.2
28+
3.1.3
29+
3.2.0
30+
3.2.1
31+
3.2.2
32+
3.3.0
33+
3.3.1
3034
```
3135

3236
Now that you've figured out what the most recent version of the Scala 3 compiler is,
3337
adapt the build to utilise this version (change `code/build.sbt`).
3438

3539
As we need to have a look at the options supported by the Scala 3 compiler, we need to install
3640
the compiler first. Let's use Coursier to do this. For example, if we want to install version
37-
3.0.2 (which certainly isn't the most recent version at this moment...), we do this as follows:
41+
3.3.0 (which certainly isn't the most recent version at this moment...), we do this as follows:
3842

3943
```bash
40-
$ cs install scalac:3.0.2
44+
$ cs install scalac:3.3.0
45+
<elided>
4146
Wrote scalac
4247

4348
$ scalac -version
44-
Scala compiler version 3.0.2 -- Copyright 2002-2021, LAMP/EPFL
49+
Scala compiler version 3.3.0 -- Copyright 2002-2023, LAMP/EPFL
4550
```
4651

4752
After having installed the compiler, we can have a look at its options.
@@ -52,38 +57,34 @@ from `scalac -help`. Note that the (reformatted) output you get from this comman
5257
may be different if you installed a different version.
5358

5459
```bash
55-
$ scalac -help
60+
$ scalac --help
5661
Usage: scalac <options> <source files>
5762
where possible standard options include:
5863
-Dproperty=value Pass -Dproperty=value directly to the runtime system.
59-
-J<flag> Pass <flag> directly to the runtime system.
60-
-P Pass an option to a plugin, e.g. -P:<plugin>:<opt>
61-
-V Print a synopsis of verbose options.
62-
-W Print a synopsis of warning options.
6364
...
64-
<elided>
65+
<elided>
6566
...
66-
-new-syntax Require `then` and `do` in control expressions.
67-
-old-syntax Require `(...)` around conditions.
67+
-new-syntax Require `then` and `do` in control expressions.
68+
-indent Together with -rewrite, remove {...} syntax when possible
69+
due to significant indentation.
70+
-no-indent Require classical {...} syntax, indentation is not
71+
significant.
72+
-old-syntax Require `(...)` around conditions.
73+
Default 80
74+
-rewrite When used in conjunction with a `...-migration` source
75+
version, rewrites sources to migrate to new version.
76+
(Scala.js only)
6877
...
69-
<elided>
78+
<elided>
7079
...
71-
-indent Together with -rewrite, remove {...} syntax when possible
72-
due to significant indentation.
73-
-no-indent Require classical {...} syntax, indentation is not
74-
significant.
80+
-source source version
81+
Default 3.3
82+
Choices : 3.0-migration, 3.0, 3.1, 3.2-migration, 3.2,
83+
3.3-migration, 3.3, future-migration, future
7584
...
76-
<elided>
85+
<elided>
7786
...
78-
-rewrite When used in conjunction with a `...-migration` source
79-
version, rewrites sources to migrate to new version.
80-
...
81-
<elided>
82-
...
83-
-source source version
84-
Default 3.2
85-
Choices 3.0-migration, 3.0, 3.1, 3.2-migration, 3.2,
86-
future-migration, future
87+
-source source version
8788
```
8889

8990
We will add some code that trigger a number of compiler warnings which can
@@ -108,8 +109,7 @@ Add the following code snippet to the `src/main/scala/org/lunatechlabs/dotty/sud
108109
root folder:
109110

110111
```scala
111-
$ git add -A
112-
$ git commit -m "Snapshot before Scala 3 compiler rewrite"
112+
$ git commit -a -m "Snapshot before Scala 3 compiler syntax rewrites"
113113
```
114114

115115
- Compile and investigate what the compiler reports.

0 commit comments

Comments
 (0)