Skip to content

Commit 9576c3e

Browse files
committed
Change some code examples to follow the Scala coding style conventions
1 parent bb83860 commit 9576c3e

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

docs/docs/reference/contextual/givens.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ object Foo:
134134
given fooTagged[A](using Tagged[A]): Foo[A] = Foo(true)
135135
given fooNotTagged[A](using NotGiven[Tagged[A]]): Foo[A] = Foo(false)
136136

137-
@main def test() =
137+
@main def test(): Unit =
138138
given Tagged[Int] with {}
139139
assert(summon[Foo[Int]].value) // fooTagged is found
140140
assert(!summon[Foo[String]].value) // fooNotTagged is found
@@ -150,7 +150,7 @@ is created for each reference.
150150

151151
Here is the syntax for given instances:
152152

153-
```
153+
```ebnf
154154
TmplDef ::= ...
155155
| ‘given’ GivenDef
156156
GivenDef ::= [GivenSig] StructuralInstance

docs/docs/reference/dropped-features/nonlocal-returns.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extension [T](xs: List[T])
1919
false
2020
}
2121

22-
@main def test =
22+
@main def test(): Unit =
2323
val xs = List(1, 2, 3, 4, 5)
2424
assert(xs.has(2) == xs.contains(2))
2525
```

docs/docs/reference/enums/desugarEnums.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ map into `case class`es or `val`s.
127127
starting from 0. The anonymous class also
128128
implements the abstract `Product` methods that it inherits from `Enum`.
129129

130-
131130
It is an error if a value case refers to a type parameter of the enclosing `enum`
132131
in a type argument of `<parents>`.
133132

@@ -198,6 +197,7 @@ Even though translated enum cases are located in the enum's companion object, re
198197
this object or its members via `this` or a simple identifier is also illegal. The compiler typechecks enum cases in the scope of the enclosing companion object but flags any such illegal accesses as errors.
199198

200199
### Translation of Java-compatible enums
200+
201201
A Java-compatible enum is an enum that extends `java.lang.Enum`. The translation rules are the same as above, with the reservations defined in this section.
202202

203203
It is a compile-time error for a Java-compatible enum to have class cases.
@@ -206,9 +206,9 @@ Cases such as `case C` expand to a `@static val` as opposed to a `val`. This all
206206

207207
### Other Rules
208208

209-
- A normal case class which is not produced from an enum case is not allowed to extend
210-
`scala.reflect.Enum`. This ensures that the only cases of an enum are the ones that are
211-
explicitly declared in it.
209+
- A normal case class which is not produced from an enum case is not allowed to extend
210+
`scala.reflect.Enum`. This ensures that the only cases of an enum are the ones that are
211+
explicitly declared in it.
212212

213-
- If an enum case has an `extends` clause, the enum class must be one of the
214-
classes that's extended.
213+
- If an enum case has an `extends` clause, the enum class must be one of the
214+
classes that's extended.

docs/docs/reference/enums/enums.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ end Planet
9393
As a library author, you may want to signal that an enum case is no longer intended for use. However you could still want to gracefully handle the removal of a case from your public API, such as special casing deprecated cases.
9494

9595
To illustrate, say that the `Planet` enum originally had an additional case:
96+
9697
```diff
9798
enum Planet(mass: Double, radius: Double):
9899
...
@@ -128,9 +129,11 @@ object Planet {
128129
}
129130
}
130131
```
132+
131133
We could imagine that a library may use [type class derivation](../contextual/derivation.md) to automatically provide an instance for `Deprecations`.
132134

133135
### Compatibility with Java Enums
136+
134137
If you want to use the Scala-defined enums as [Java enums](https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html), you can do so by extending
135138
the class `java.lang.Enum`, which is imported by default, as follows:
136139

docs/docs/reference/metaprogramming/tasty-inspect.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ import scala.quoted.*
2222
import scala.tasty.inspector.*
2323

2424
class MyInspector extends Inspector:
25-
def inspect(using Quotes)(tastys: List[Tasty[quotes.type]]): Unit =
25+
def inspect(using Quotes)(tastys: List[Tasty[quotes.type]]): Unit =
2626
import quotes.reflect.*
2727
for tasty <- tastys do
28-
val tree = tasty.ast
29-
// Do something with the tree
28+
val tree = tasty.ast
29+
// Do something with the tree
3030
```
3131

3232
Then the consumer can be instantiated with the following code to get the tree of the `foo/Bar.tasty` file.
@@ -36,7 +36,6 @@ object Test:
3636
def main(args: Array[String]): Unit =
3737
val tastyFiles = List("foo/Bar.tasty")
3838
TastyInspector.inspectTastyFiles(tastyFiles)(new MyInspector)
39-
4039
```
4140

4241
Note that if we need to run the main (in the example below defined in an object called `Test`) after compilation we need to make the compiler available to the runtime:

0 commit comments

Comments
 (0)