@@ -11,12 +11,6 @@ import NameKinds.DefaultGetterName
11
11
import Annotations .Annotation
12
12
13
13
object MainProxies {
14
-
15
- /** Generate proxy classes for @main functions and @myMain functions where myMain <:< MainAnnotation */
16
- def proxies (stats : List [tpd.Tree ])(using Context ): List [untpd.Tree ] = {
17
- mainAnnotationProxies(stats) ++ mainProxies(stats)
18
- }
19
-
20
14
/** Generate proxy classes for @main functions.
21
15
* A function like
22
16
*
@@ -35,7 +29,7 @@ object MainProxies {
35
29
* catch case err: ParseError => showError(err)
36
30
* }
37
31
*/
38
- private def mainProxies (stats : List [tpd.Tree ])(using Context ): List [untpd.Tree ] = {
32
+ def mainProxiesOld (stats : List [tpd.Tree ])(using Context ): List [untpd.Tree ] = {
39
33
import tpd ._
40
34
def mainMethods (stats : List [Tree ]): List [Symbol ] = stats.flatMap {
41
35
case stat : DefDef if stat.symbol.hasAnnotation(defn.MainAnnot ) =>
@@ -45,11 +39,11 @@ object MainProxies {
45
39
case _ =>
46
40
Nil
47
41
}
48
- mainMethods(stats).flatMap(mainProxy )
42
+ mainMethods(stats).flatMap(mainProxyOld )
49
43
}
50
44
51
45
import untpd ._
52
- private def mainProxy (mainFun : Symbol )(using Context ): List [TypeDef ] = {
46
+ def mainProxyOld (mainFun : Symbol )(using Context ): List [TypeDef ] = {
53
47
val mainAnnotSpan = mainFun.getAnnotation(defn.MainAnnot ).get.tree.span
54
48
def pos = mainFun.sourcePos
55
49
val argsRef = Ident (nme.args)
@@ -171,7 +165,7 @@ object MainProxies {
171
165
* }
172
166
* }
173
167
*/
174
- private def mainAnnotationProxies (stats : List [tpd.Tree ])(using Context ): List [untpd.Tree ] = {
168
+ def mainProxies (stats : List [tpd.Tree ])(using Context ): List [untpd.Tree ] = {
175
169
import tpd ._
176
170
177
171
/**
@@ -194,12 +188,12 @@ object MainProxies {
194
188
def mainMethods (scope : Tree , stats : List [Tree ]): List [(Symbol , ParameterAnnotationss , DefaultValueSymbols , Option [Comment ])] = stats.flatMap {
195
189
case stat : DefDef =>
196
190
val sym = stat.symbol
197
- sym.annotations.filter(_.matches(defn.MainAnnotationClass )) match {
191
+ sym.annotations.filter(_.matches(defn.MainAnnot )) match {
198
192
case Nil =>
199
193
Nil
200
194
case _ :: Nil =>
201
195
val paramAnnotations = stat.paramss.flatMap(_.map(
202
- valdef => valdef.symbol.annotations.filter(_.matches(defn.MainAnnotationParameterAnnotation ))
196
+ valdef => valdef.symbol.annotations.filter(_.matches(defn.MainAnnotParameterAnnotation ))
203
197
))
204
198
(sym, paramAnnotations.toVector, defaultValueSymbols(scope, sym), stat.rawComment) :: Nil
205
199
case mainAnnot :: others =>
@@ -213,7 +207,7 @@ object MainProxies {
213
207
}
214
208
215
209
// Assuming that the top-level object was already generated, all main methods will have a scope
216
- mainMethods(EmptyTree , stats).flatMap(mainAnnotationProxy )
210
+ mainMethods(EmptyTree , stats).flatMap(mainProxy )
217
211
}
218
212
219
213
private def mainAnnotationProxy (mainFun : Symbol , paramAnnotations : ParameterAnnotationss , defaultValueSymbols : DefaultValueSymbols , docComment : Option [Comment ])(using Context ): Option [TypeDef ] = {
@@ -367,7 +361,7 @@ object MainProxies {
367
361
case tree => super .transform(tree)
368
362
}
369
363
val annots = mainFun.annotations
370
- .filterNot(_.matches(defn.MainAnnotationClass ))
364
+ .filterNot(_.matches(defn.MainAnnot ))
371
365
.map(annot => insertTypeSplices.transform(annot.tree))
372
366
val mainMeth = DefDef (nme.main, (mainArg :: Nil ) :: Nil , TypeTree (defn.UnitType ), body)
373
367
.withFlags(JavaStatic )
0 commit comments