Skip to content

Commit 4f752bd

Browse files
committed
Simplify generation of ParamInfo.withAnnotations
1 parent 7d58e8c commit 4f752bd

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,12 @@ object MainProxies {
247247

248248
val constructorArgs = List(param, paramTypeStr, hasDefault, isRepeated, paramDoc)
249249
.map(value => Literal(Constant(value)))
250-
251-
var paramInfos =
250+
val paramInfos =
252251
New(TypeTree(defn.MainAnnotationParameterInfo.typeRef), List(constructorArgs))
253-
254252
val paramAnnots = paramAnnotations(idx)
255253
if paramAnnots.nonEmpty then
256-
paramInfos = paramInfos.withProperty(defn.MainAnnotationParameterInfo_withAnnotations, paramAnnots.map(instantiateAnnotation).toList)
257-
258-
paramInfos
254+
paramInfos.withProperty(defn.MainAnnotationParameterInfo_withAnnotations, paramAnnots.map(instantiateAnnotation).toList)
255+
else paramInfos
259256
end parameterInfos
260257

261258
/**

library/src/scala/annotation/MainAnnotation.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ trait MainAnnotation extends StaticAnnotation:
2424

2525
/** A new command with arguments from `args` */
2626
def command(args: Array[String], commandName: String, documentation: String, parameterInfos: ParameterInfo*): Command[Parser, Result]
27+
2728
end MainAnnotation
2829

2930
@experimental
@@ -37,6 +38,7 @@ object MainAnnotation:
3738
paramDocumentation: String,
3839
paramAnnotations: Seq[ParameterAnnotation],
3940
) {
41+
4042
/** ParameterInfo with a name, the type of the parameter and if it has a default */
4143
def this(name: String, typeName: String, hasDefault: Boolean, isVarargs: Boolean, documentation: String) =
4244
this(name, typeName, hasDefault, isVarargs, documentation, Seq.empty)
@@ -83,4 +85,5 @@ object MainAnnotation:
8385

8486
/** Marker trait for annotations that will be included in the ParameterInfo annotations. */
8587
trait ParameterAnnotation extends StaticAnnotation
88+
8689
end MainAnnotation

0 commit comments

Comments
 (0)