Skip to content

fix indentation of diff blocks #2728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions _overviews/scala3-migration/incompat-syntactic.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The [Scala 3 migration compilation](tooling-migration-mode.html) rewrites the co

- println(enum)
+ println(`enum`)
}
}
{% endhighlight %}

## Procedure Syntax
Expand All @@ -84,12 +84,12 @@ object Bar {

The [Scala 3 migration compilation](tooling-migration-mode.html) rewrites the code into.
{% highlight diff %}
object Bar {
object Bar {
- def print() {
+ def print(): Unit = {
println("bar")
}
}
println("bar")
}
}
{% endhighlight %}

## Parentheses Around Lambda Parameter
Expand Down Expand Up @@ -129,30 +129,30 @@ test("my test")

The [Scala 3 migration compiler](tooling-migration-mode.html) indents the first line of the block.
{% highlight diff %}
test("my test")
test("my test")
-{
+ {
assert(1 == 1)
}
assert(1 == 1)
}
{% endhighlight %}

This migration rule applies to other patterns as well, such as refining a type after a new line.

{% highlight diff %}
type Bar = Foo
- {
+ {
def bar(): Int
}
type Bar = Foo
-{
+ {
def bar(): Int
}
{% endhighlight %}

A preferable solution is to write:
{% highlight diff %}
-test("my test")
-{
+test("my test") {
assert(1 == 1)
}
assert(1 == 1)
}
{% endhighlight %}

## Wrong indentation
Expand All @@ -175,12 +175,12 @@ def bar: (Int, Int) = {

The indentation must be fixed.
{% highlight diff %}
def bar: (Int, Int) = {
val foo = 1.0
val bar = foo
def bar: (Int, Int) = {
val foo = 1.0
val bar = foo
- (1, 1)
+ (1, 1)
}
}
{% endhighlight %}

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).
Expand Down