Skip to content

Commit 4eb72ae

Browse files
Update example in MainProxies
1 parent 6353daa commit 4eb72ae

File tree

1 file changed

+34
-22
lines changed

1 file changed

+34
-22
lines changed

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

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,40 @@ import NameKinds.DefaultGetterName
1111
import Annotations.Annotation
1212

1313
/** Generate proxy classes for main functions.
14-
* A function like
15-
*
16-
* /**
17-
* * Lorem ipsum dolor sit amet
18-
* * consectetur adipiscing elit.
19-
* *
20-
* * @param x my param x
21-
* * @param ys all my params y
22-
* */
23-
* @main(80) def f(x: S, ys: T*) = ...
24-
*
25-
* would be translated to something like
26-
*
27-
* final class f {
28-
* @static def main(args: Array[String]): Unit =
29-
* val cmd: MainAnnotation#Command[..., ...] =
30-
* (new scala.main(80)).command(args, "f", "Lorem ipsum dolor sit amet consectetur adipiscing elit.")
31-
* val arg1: () => S = cmd.argGetter[S]("x", "S", "my param x")
32-
* val arg2: () => Seq[T] = cmd.argsGetter[T]("ys", "T", "all my params y")
33-
* cmd.run(f(arg1(), arg2()*))
34-
* }
35-
*/
14+
* A function like
15+
*
16+
* /**
17+
* * Lorem ipsum dolor sit amet
18+
* * consectetur adipiscing elit.
19+
* *
20+
* * @param x my param x
21+
* * @param ys all my params y
22+
* */
23+
* @main(80) def f(@main.arg(shortName = 'x', name = "myX") x: S, ys: T*) = ...
24+
*
25+
* would be translated to something like
26+
*
27+
* final class f {
28+
* static def main(args: Array[String]): Unit = {
29+
* val cmd = new main(80).command(args, "f", "Lorem ipsum dolor sit amet consectetur adipiscing elit.")
30+
*
31+
* val args0: () => S = cmd.argGetter[S]({
32+
* val args0paramInfos = new scala.annotation.MainAnnotation.ParameterInfos[S]("x", "S")
33+
* args0paramInfos.documentation = Some("my param x")
34+
* args0paramInfos.annotation = Some(new scala.main.arg(name = "myX", shortName = 'x'))
35+
* args0paramInfos
36+
* })(util.CommandLineParser.FromString.given_FromString_Int)
37+
*
38+
* val args1: () => Seq[T] = cmd.varargGetter[T]({
39+
* val args1paramInfos = new scala.annotation.MainAnnotation.ParameterInfos[T]("ys", "T")
40+
* args1paramInfos.documentation = Some("all my params y")
41+
* args1paramInfos
42+
* })(util.CommandLineParser.FromString.given_FromString_String)
43+
*
44+
* cmd.run(f(args0.apply(), args1.apply()*))
45+
* }
46+
* }
47+
*/
3648
object MainProxies {
3749

3850
def mainProxies(stats: List[tpd.Tree])(using Context): List[untpd.Tree] = {

0 commit comments

Comments
 (0)