Skip to content

Commit 97c1cd2

Browse files
committed
Make main proxies final and docs fixes
1 parent fce621c commit 97c1cd2

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

compiler/src/dotty/tools/dotc/ast/MainProxies.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ object MainProxies {
9393
.withFlags(JavaStatic)
9494
val mainTempl = Template(emptyConstructor, Nil, Nil, EmptyValDef, mainMeth :: Nil)
9595
val mainCls = TypeDef(mainFun.name.toTypeName, mainTempl)
96+
.withFlags(Final)
9697
if (!ctx.reporter.hasErrors) result = mainCls.withSpan(mainAnnotSpan) :: Nil
9798
}
9899
result

docs/docs/reference/changed-features/main-functions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: "Main Methods"
44
---
55

66
Scala 3 offers a new way to define programs that can be invoked from the command line:
7-
A @main annotation on a method turns this method into an executable program.
7+
A `@main` annotation on a method turns this method into an executable program.
88
Example:
99
```scala
1010
@main def happyBirthday(age: Int, name: String, others: String*) = {
@@ -55,7 +55,7 @@ The Scala compiler generates a program from a `@main` method `f` as follows:
5555

5656
For instance, the `happyBirthDay` method above would generate additional code equivalent to the following class:
5757
```scala
58-
class happyBirthday {
58+
final class happyBirthday {
5959
import scala.util.{CommndLineParser => CLP}
6060
<static> def main(args: Array[String]): Unit =
6161
try
@@ -79,4 +79,4 @@ as a static method of class `happyBirthDay`. It is not available for user progra
7979
}
8080
```
8181
The previous functionality of `App`, which relied on the "magic" `DelayedInit` trait, is no longer available. `App` still exists in limited form for now, but it does not support command line arguments and will be deprecated in the future. If programs need to cross-build
82-
between Scala 2 and Scala 3, it is recommende to use an explicit `main` method with an `Array[String] argument instead.
82+
between Scala 2 and Scala 3, it is recommended to use an explicit `main` method with an `Array[String]` argument instead.

0 commit comments

Comments
 (0)