Skip to content

Commit 1f3142e

Browse files
committed
Update docs
1 parent 64ec37e commit 1f3142e

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ object MainProxies {
162162
* val command = annot.command(info, args)
163163
* if command.isDefined then
164164
* val cmd = command.get
165-
* val args0: () => S = annotation.argGetter[S](0, cmd(0), None)
166-
* val args1: () => S = annotation.argGetter[S](1, cmd(1), None)
167-
* val args2: () => Seq[T] = annotation.varargGetter[T](cmd.drop(2))
168-
* annotation.run(() => f(args0(), args1()*))
165+
* val args0: () => S = annotation.argGetter[S](info.parameters(0), cmd(0), None)
166+
* val args1: () => S = annotation.argGetter[S](info.parameters(1), mainArgs(1), Some(() => sum$default$1()))
167+
* val args2: () => Seq[T] = annotation.varargGetter[T](info.parameters(2), cmd.drop(2))
168+
* annotation.run(() => f(args0(), args1(), args2()*))
169169
* }
170170
* }
171171
*/

docs/_docs/reference/experimental/main-annotation.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ object foo {
2525
documentation = "Sum all the numbers",
2626
parameters = Seq(
2727
new ParameterInfo("first", "scala.Int", hasDefault=false, isVarargs=false, "Fist number to sum", Seq()),
28+
new ParameterInfo("second", "scala.Int", hasDefault=true, isVarargs=false, "", Seq()),
2829
new ParameterInfo("rest", "scala.Int" , hasDefault=false, isVarargs=true, "The rest of the numbers to sum", Seq())
2930
)
3031
)
@@ -39,8 +40,8 @@ object foo {
3940
}
4041
```
4142

42-
The implementation of the `main` method first instantiates the annotation and then creates a `Command`.
43-
When creating the `Command`, the arguments can be checked and preprocessed.
43+
The implementation of the `main` method first instantiates the annotation and then call `command`.
44+
When calling the `command`, the arguments can be checked and preprocessed.
4445
Then it defines a series of argument getters calling `argGetter` for each parameter and `varargGetter` for the last one if it is a varargs. `argGetter` gets an optional lambda that computes the default argument.
4546
Finally, the `run` method is called to run the application. It receives a by-name argument that contains the call the annotated method with the instantiations arguments (using the lambdas from `argGetter`/`varargGetter`).
4647

0 commit comments

Comments
 (0)