Skip to content

Commit ff4e8ca

Browse files
Update comments in MainProxies
1 parent 569bcba commit ff4e8ca

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,27 @@ import Annotations.Annotation
2020
* * @param x my param x
2121
* * @param ys all my params y
2222
* */
23-
* @main(80) def f(@main.arg(shortName = 'x', name = "myX") x: S, ys: T*) = ...
23+
* @main(80) def f(
24+
* @main.ShortName('x') @main.Name("myX") x: S,
25+
* ys: T*
26+
* ) = ...
2427
*
2528
* would be translated to something like
2629
*
2730
* final class f {
2831
* static def main(args: Array[String]): Unit = {
2932
* val cmd = new main(80).command(args, "f", "Lorem ipsum dolor sit amet consectetur adipiscing elit.")
3033
*
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)
34+
* val args0: () => S = cmd.argGetter[S](
35+
* new scala.annotation.MainAnnotation.ParameterInfos[S]("x", "S")
36+
* .withDocumentation("my param x")
37+
* .withAnnotations(new scala.main.ShortName('x'), new scala.main.Name("myX"))
38+
* )
3739
*
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)
40+
* val args1: () => Seq[T] = cmd.varargGetter[T](
41+
* new scala.annotation.MainAnnotation.ParameterInfos[T]("ys", "T")
42+
* .withDocumentation("all my params y")
43+
* )
4344
*
4445
* cmd.run(f(args0.apply(), args1.apply()*))
4546
* }
@@ -103,10 +104,13 @@ object MainProxies {
103104

104105
val documentation = new Documentation(docComment)
105106

107+
/** A literal value (Boolean, Int, String, etc.) */
106108
inline def lit(any: Any): Literal = Literal(Constant(any))
107109

110+
/** Some(value) */
108111
inline def some(value: Tree): Tree = Apply(ref(defn.SomeClass.companionModule.termRef), value)
109112

113+
/** () => value */
110114
def unitToValue(value: Tree): Tree =
111115
val anonName = nme.ANON_FUN
112116
val defdef = DefDef(anonName, List(Nil), TypeTree(), value)
@@ -116,7 +120,7 @@ object MainProxies {
116120
* Creates a list of references and definitions of arguments, the first referencing the second.
117121
* The goal is to create the
118122
* `val arg0: () => S = ...`
119-
* part of the code. The first element of the tuple is a ref to `arg0`, the second is the whole definition.
123+
* part of the code. The first element of a tuple is a ref to `arg0`, the second is the whole definition.
120124
*/
121125
def createArgs(mt: MethodType, cmdName: TermName): List[(Tree, ValDef)] =
122126
mt.paramInfos.zip(mt.paramNames).zipWithIndex.map {
@@ -151,9 +155,9 @@ object MainProxies {
151155
/*
152156
* Assignations to be made after the creation of the ParameterInfos.
153157
* For example:
154-
* args0paramInfos.withDocumentation = Some("my param x")
158+
* args0paramInfos.withDocumentation("my param x")
155159
* is represented by the pair
156-
* (defn.MainAnnotationParameterInfos_withDocumentation, some(lit("my param x")))
160+
* (defn.MainAnnotationParameterInfos_withDocumentation, List(lit("my param x")))
157161
*/
158162
var assignations: List[(Symbol, List[Tree])] = Nil
159163
for (dvSym <- defaultValueSymbols.get(n))

0 commit comments

Comments
 (0)