Skip to content

Commit edc34e8

Browse files
committed
Rename ParameterInfos to ParameterInfo
1 parent 618c631 commit edc34e8

8 files changed

+42
-35
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ object MainProxies {
152152
* args,
153153
* "f",
154154
* "Lorem ipsum dolor sit amet consectetur adipiscing elit.",
155-
* new scala.annotation.MainAnnotation.ParameterInfos("x", "S")
155+
* new scala.annotation.MainAnnotation.ParameterInfo("x", "S")
156156
* .withDocumentation("my param x")
157157
* .withAnnotations(new scala.main.Alias("myX")),
158-
* new scala.annotation.MainAnnotation.ParameterInfos("ys", "T")
158+
* new scala.annotation.MainAnnotation.ParameterInfo("ys", "T")
159159
* .withDocumentation("all my params y")
160160
* )
161161
*
@@ -170,8 +170,8 @@ object MainProxies {
170170
import tpd._
171171

172172
/**
173-
* Computes the symbols of the default values of the function. Since they cannot be infered anymore at this
174-
* point of the compilation, they must be explicitely passed by [[mainProxy]].
173+
* Computes the symbols of the default values of the function. Since they cannot be inferred anymore at this
174+
* point of the compilation, they must be explicitly passed by [[mainProxy]].
175175
*/
176176
def defaultValueSymbols(scope: Tree, funSymbol: Symbol): DefaultValueSymbols =
177177
scope match {
@@ -239,7 +239,7 @@ object MainProxies {
239239
* `val args0: () => S = cmd.argGetter[S]("x", None)`
240240
* part of the code.
241241
* For each tuple, the first element is a ref to `args0`, the second is the whole definition, the third
242-
* is the ParameterInfos definition associated to this argument.
242+
* is the ParameterInfo definition associated to this argument.
243243
*/
244244
def createArgs(mt: MethodType, cmdName: TermName): List[(Tree, ValDef, Tree)] =
245245
mt.paramInfos.zip(mt.paramNames).zipWithIndex.map {
@@ -254,29 +254,29 @@ object MainProxies {
254254
else (argRef0, formal, defn.MainAnnotationCommand_argGetter)
255255
}
256256

257-
// The ParameterInfos
257+
// The ParameterInfo
258258
val parameterInfos = {
259259
val param = paramName.toString
260260
val paramInfosTree = New(
261-
TypeTree(defn.MainAnnotationParameterInfos.typeRef),
262-
// Arguments to be passed to ParameterInfos' constructor
261+
TypeTree(defn.MainAnnotationParameterInfo.typeRef),
262+
// Arguments to be passed to ParameterInfo' constructor
263263
List(List(lit(param), lit(formalType.show)))
264264
)
265265

266266
/*
267-
* Assignations to be made after the creation of the ParameterInfos.
267+
* Assignations to be made after the creation of the ParameterInfo.
268268
* For example:
269269
* args0paramInfos.withDocumentation("my param x")
270270
* is represented by the pair
271-
* defn.MainAnnotationParameterInfos_withDocumentation -> List(lit("my param x"))
271+
* defn.MainAnnotationParameterInfo_withDocumentation -> List(lit("my param x"))
272272
*/
273273
var assignations: List[(Symbol, List[Tree])] = Nil
274274
for (doc <- documentation.argDocs.get(param))
275-
assignations = (defn.MainAnnotationParameterInfos_withDocumentation -> List(lit(doc))) :: assignations
275+
assignations = (defn.MainAnnotationParameterInfo_withDocumentation -> List(lit(doc))) :: assignations
276276

277277
val instanciatedAnnots = paramAnnotations(n).map(instanciateAnnotation).toList
278278
if instanciatedAnnots.nonEmpty then
279-
assignations = (defn.MainAnnotationParameterInfos_withAnnotations -> instanciatedAnnots) :: assignations
279+
assignations = (defn.MainAnnotationParameterInfo_withAnnotations -> instanciatedAnnots) :: assignations
280280

281281
assignations.foldLeft[Tree](paramInfosTree){ case (tree, (setterSym, values)) => Apply(Select(tree, setterSym.name), values) }
282282
}

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,9 +851,9 @@ class Definitions {
851851

852852
@tu lazy val MainAnnotationClass: ClassSymbol = requiredClass("scala.annotation.MainAnnotation")
853853
@tu lazy val MainAnnotation_command: Symbol = MainAnnotationClass.requiredMethod("command")
854-
@tu lazy val MainAnnotationParameterInfos: ClassSymbol = requiredClass("scala.annotation.MainAnnotation.ParameterInfos")
855-
@tu lazy val MainAnnotationParameterInfos_withDocumentation: Symbol = MainAnnotationParameterInfos.requiredMethod("withDocumentation")
856-
@tu lazy val MainAnnotationParameterInfos_withAnnotations: Symbol = MainAnnotationParameterInfos.requiredMethod("withAnnotations")
854+
@tu lazy val MainAnnotationParameterInfo: ClassSymbol = requiredClass("scala.annotation.MainAnnotation.ParameterInfo")
855+
@tu lazy val MainAnnotationParameterInfo_withDocumentation: Symbol = MainAnnotationParameterInfo.requiredMethod("withDocumentation")
856+
@tu lazy val MainAnnotationParameterInfo_withAnnotations: Symbol = MainAnnotationParameterInfo.requiredMethod("withAnnotations")
857857
@tu lazy val MainAnnotationParameterAnnotation: ClassSymbol = requiredClass("scala.annotation.MainAnnotation.ParameterAnnotation")
858858
@tu lazy val MainAnnotationCommand: ClassSymbol = requiredClass("scala.annotation.MainAnnotation.Command")
859859
@tu lazy val MainAnnotationCommand_argGetter: Symbol = MainAnnotationCommand.requiredMethod("argGetter")

library/src/scala/annotation/MainAnnotation.scala

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ package scala.annotation
1212
*/
1313
@experimental
1414
trait MainAnnotation extends StaticAnnotation:
15+
import MainAnnotation.*
1516

1617
/** The class used for argument string parsing. E.g. `scala.util.CommandLineParser.FromString`,
1718
* but could be something else
@@ -22,13 +23,13 @@ trait MainAnnotation extends StaticAnnotation:
2223
type MainResultType
2324

2425
/** A new command with arguments from `args` */
25-
def command(args: Array[String], commandName: String, documentation: String, parameterInfoss: MainAnnotation.ParameterInfos*): MainAnnotation.Command[ArgumentParser, MainResultType]
26+
def command(args: Array[String], commandName: String, documentation: String, parameterInfos: ParameterInfo*): Command[ArgumentParser, MainResultType]
2627
end MainAnnotation
2728

2829
@experimental
2930
object MainAnnotation:
3031

31-
final class ParameterInfos private (
32+
final class ParameterInfo private (
3233
/** The name of the parameter */
3334
val name: String,
3435
/** The name of the parameter's type */
@@ -38,17 +39,17 @@ object MainAnnotation:
3839
/** The ParameterAnnotations associated with the parameter. Defaults to Seq.empty. */
3940
val annotations: Seq[ParameterAnnotation],
4041
) {
41-
/** ParameterInfos with a name and the type of the parameter */
42+
/** ParameterInfo with a name and the type of the parameter */
4243
def this(name: String, typeName: String) =
4344
this(name, typeName, None, Seq.empty)
4445

45-
/** Copy this ParameterInfos and sets the documentation */
46-
def withDocumentation(doc: String): ParameterInfos =
47-
new ParameterInfos(name, typeName, Some(doc), annotations)
46+
/** Copy this ParameterInfo and sets the documentation */
47+
def withDocumentation(doc: String): ParameterInfo =
48+
new ParameterInfo(name, typeName, Some(doc), annotations)
4849

49-
/** Copy this ParameterInfos and sets the annotations */
50-
def withAnnotations(annots: ParameterAnnotation*): ParameterInfos =
51-
new ParameterInfos(name, typeName, documentation, annots)
50+
/** Copy this ParameterInfo and sets the annotations */
51+
def withAnnotations(annots: ParameterAnnotation*): ParameterInfo =
52+
new ParameterInfo(name, typeName, documentation, annots)
5253

5354
override def toString: String = s"$name: $typeName"
5455
}
@@ -68,6 +69,6 @@ object MainAnnotation:
6869
def run(program: => MainResultType): Unit
6970
end Command
7071

71-
/** Marker trait for annotations that will be included in the ParameterInfos annotations. */
72+
/** Marker trait for annotations that will be included in the ParameterInfo annotations. */
7273
trait ParameterAnnotation extends StaticAnnotation
7374
end MainAnnotation

tests/run/main-annotation-homemade-annot-1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ end Test
2222

2323
@experimental
2424
class mainAwait(timeout: Int = 2) extends MainAnnotation:
25-
import MainAnnotation._
25+
import MainAnnotation.*
2626

2727
override type ArgumentParser[T] = util.CommandLineParser.FromString[T]
2828
override type MainResultType = Future[Any]
2929

3030
// This is a toy example, it only works with positional args
31-
override def command(args: Array[String], commandName: String, docComment: String, parameterInfos: MainAnnotation.ParameterInfos*) =
31+
override def command(args: Array[String], commandName: String, docComment: String, parameterInfos: ParameterInfo*) =
3232
new Command[ArgumentParser, MainResultType]:
3333
private var idx = 0
3434

tests/run/main-annotation-homemade-annot-2.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ end Test
2929
// This is a toy example, it only works with positional args
3030
@experimental
3131
class myMain(runs: Int = 3)(after: String*) extends MainAnnotation:
32-
import MainAnnotation._
32+
import MainAnnotation.*
3333

3434
override type ArgumentParser[T] = util.CommandLineParser.FromString[T]
3535
override type MainResultType = Any
3636

37-
override def command(args: Array[String], commandName: String, docComment: String, parameterInfos: MainAnnotation.ParameterInfos*) =
37+
override def command(args: Array[String], commandName: String, docComment: String, parameterInfos: ParameterInfo*) =
3838
new Command[ArgumentParser, MainResultType]:
3939
private var idx = 0
4040

tests/run/main-annotation-homemade-annot-3.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ end Test
1111

1212
@experimental
1313
class mainNoArgs extends MainAnnotation:
14+
import MainAnnotation.*
15+
1416
override type ArgumentParser[T] = util.CommandLineParser.FromString[T]
1517
override type MainResultType = Any
1618

17-
override def command(args: Array[String], commandName: String, docComment: String, parameterInfos: MainAnnotation.ParameterInfos*) =
18-
new MainAnnotation.Command[ArgumentParser, MainResultType]:
19+
override def command(args: Array[String], commandName: String, docComment: String, parameterInfos: ParameterInfo*) =
20+
new Command[ArgumentParser, MainResultType]:
1921
override def argGetter[T](name: String, optDefaultValueGetter: Option[() => T])(using p: ArgumentParser[T]): () => T = ???
2022

2123
override def varargGetter[T](name: String)(using p: ArgumentParser[T]): () => Seq[T] = ???

tests/run/main-annotation-homemade-annot-4.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ end Test
1111

1212
@experimental
1313
class mainManyArgs(i1: Int, s2: String, i3: Int) extends MainAnnotation:
14+
import MainAnnotation.*
15+
1416
override type ArgumentParser[T] = util.CommandLineParser.FromString[T]
1517
override type MainResultType = Any
1618

17-
override def command(args: Array[String], commandName: String, docComment: String, parameterInfos: MainAnnotation.ParameterInfos*) =
18-
new MainAnnotation.Command[ArgumentParser, MainResultType]:
19+
override def command(args: Array[String], commandName: String, docComment: String, parameterInfos: ParameterInfo*) =
20+
new Command[ArgumentParser, MainResultType]:
1921
override def argGetter[T](name: String, optDefaultGetter: Option[() => T])(using p: ArgumentParser[T]): () => T = ???
2022

2123
override def varargGetter[T](name: String)(using p: ArgumentParser[T]): () => Seq[T] = ???

tests/run/main-annotation-homemade-annot-5.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ end Test
1313

1414
@experimental
1515
class mainManyArgs(o: Option[Int]) extends MainAnnotation:
16+
import MainAnnotation.*
17+
1618
override type ArgumentParser[T] = util.CommandLineParser.FromString[T]
1719
override type MainResultType = Any
1820

19-
override def command(args: Array[String], commandName: String, docComment: String, parameterInfos: MainAnnotation.ParameterInfos*) =
20-
new MainAnnotation.Command[ArgumentParser, MainResultType]:
21+
override def command(args: Array[String], commandName: String, docComment: String, parameterInfos: ParameterInfo*) =
22+
new Command[ArgumentParser, MainResultType]:
2123
override def argGetter[T](name: String, optDefaultValueGetter: Option[() => T])(using p: ArgumentParser[T]): () => T = ???
2224

2325
override def varargGetter[T](name: String)(using p: ArgumentParser[T]): () => Seq[T] = ???

0 commit comments

Comments
 (0)