Skip to content

Commit eeb3aa5

Browse files
committed
Fix ParamInfo documentation and annotations
1 parent e80ef65 commit eeb3aa5

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,11 @@ object MainProxies {
258258
* defn.MainAnnotationParameterInfo_withDocumentation -> List(Literal("my param x")))
259259
*/
260260
for doc <- documentation.argDocs.get(param) do
261-
paramInfos.withProperty(defn.MainAnnotationParameterInfo_withDocumentation, List(Literal(Constant(doc))))
261+
paramInfos = paramInfos.withProperty(defn.MainAnnotationParameterInfo_withDocumentation, List(Literal(Constant(doc))))
262262

263263
val paramAnnots = paramAnnotations(idx)
264264
if paramAnnots.nonEmpty then
265-
paramInfos.withProperty(defn.MainAnnotationParameterInfo_withAnnotations, paramAnnots.map(instantiateAnnotation).toList)
265+
paramInfos = paramInfos.withProperty(defn.MainAnnotationParameterInfo_withAnnotations, paramAnnots.map(instantiateAnnotation).toList)
266266

267267
paramInfos
268268
end parameterInfos

tests/run/main-annotation-homemade-annot-6.check

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ command(
22
Array(),
33
foo,
44
"Foo docs",
5-
Seq( ParameterInfo(name="i", typeName="scala.Int", hasDefault=false, isVarargs=false, documentation=None, annotations=List()),
5+
Seq(
6+
ParameterInfo(name="i", typeName="scala.Int", hasDefault=false, isVarargs=false, documentation=None, annotations=List()),
67
ParameterInfo(name="j", typeName="java.lang.String", hasDefault=true, isVarargs=false, documentation=None, annotations=List())
78
)*
89
)
@@ -15,7 +16,8 @@ command(
1516
Array(),
1617
bar,
1718
"Bar docs",
18-
Seq( ParameterInfo(name="i", typeName="scala.collection.immutable.List[Int]", hasDefault=false, isVarargs=false, documentation=None, annotations=List()),
19+
Seq(
20+
ParameterInfo(name="i", typeName="scala.collection.immutable.List[Int]", hasDefault=false, isVarargs=false, documentation=Some("the first parameter"), annotations=ArraySeq(MyParamAnnot(3))),
1921
ParameterInfo(name="rest", typeName="scala.Int", hasDefault=false, isVarargs=true, documentation=None, annotations=List())
2022
)*
2123
)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import scala.annotation.*
66
*
77
* @param i the first parameter
88
*/
9-
@myMain def bar(i: List[Int], rest: Int*) = println(s"bar($i, ${rest.mkString(", ")})")
9+
@myMain def bar(@MyParamAnnot(3) i: List[Int], rest: Int*) = println(s"bar($i, ${rest.mkString(", ")})")
1010

1111
object Test:
1212
def main(args: Array[String]) =
@@ -49,6 +49,9 @@ class myMain extends MainAnnotation:
4949
println()
5050
end command
5151

52+
@experimental
53+
case class MyParamAnnot(n: Int) extends MainAnnotation.ParameterAnnotation
54+
5255
trait Make[T]:
5356
def make: T
5457

0 commit comments

Comments
 (0)