You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _overviews/scala3-migration/incompat-syntactic.md
+19-19
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,7 @@ The [Scala 3 migration compilation](tooling-migration-mode.html) rewrites the co
61
61
62
62
- println(enum)
63
63
+ println(`enum`)
64
-
}
64
+
}
65
65
{% endhighlight %}
66
66
67
67
## Procedure Syntax
@@ -84,12 +84,12 @@ object Bar {
84
84
85
85
The [Scala 3 migration compilation](tooling-migration-mode.html) rewrites the code into.
86
86
{% highlight diff %}
87
-
object Bar {
87
+
object Bar {
88
88
- def print() {
89
89
+ def print(): Unit = {
90
-
println("bar")
91
-
}
92
-
}
90
+
println("bar")
91
+
}
92
+
}
93
93
{% endhighlight %}
94
94
95
95
## Parentheses Around Lambda Parameter
@@ -129,30 +129,30 @@ test("my test")
129
129
130
130
The [Scala 3 migration compiler](tooling-migration-mode.html) indents the first line of the block.
131
131
{% highlight diff %}
132
-
test("my test")
132
+
test("my test")
133
133
-{
134
134
+ {
135
-
assert(1 == 1)
136
-
}
135
+
assert(1 == 1)
136
+
}
137
137
{% endhighlight %}
138
138
139
139
This migration rule applies to other patterns as well, such as refining a type after a new line.
140
140
141
141
{% highlight diff %}
142
-
type Bar = Foo
143
-
-{
144
-
+{
145
-
def bar(): Int
146
-
}
142
+
type Bar = Foo
143
+
-{
144
+
+ {
145
+
def bar(): Int
146
+
}
147
147
{% endhighlight %}
148
148
149
149
A preferable solution is to write:
150
150
{% highlight diff %}
151
151
-test("my test")
152
152
-{
153
153
+test("my test") {
154
-
assert(1 == 1)
155
-
}
154
+
assert(1 == 1)
155
+
}
156
156
{% endhighlight %}
157
157
158
158
## Wrong indentation
@@ -175,12 +175,12 @@ def bar: (Int, Int) = {
175
175
176
176
The indentation must be fixed.
177
177
{% highlight diff %}
178
-
def bar: (Int, Int) = {
179
-
val foo = 1.0
180
-
val bar = foo
178
+
def bar: (Int, Int) = {
179
+
val foo = 1.0
180
+
val bar = foo
181
181
- (1, 1)
182
182
+ (1, 1)
183
-
}
183
+
}
184
184
{% endhighlight %}
185
185
186
186
These errors can be prevented by using a Scala formatting tool such as [scalafmt](https://scalameta.org/scalafmt/) or the [IntelliJ Scala formatter](https://www.jetbrains.com/help/idea/reformat-and-rearrange-code.html).
0 commit comments