Skip to content

Commit

Permalink
Remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeandres committed Feb 6, 2022
1 parent fc1fba6 commit f1bc063
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
10 changes: 3 additions & 7 deletions compiler/src/dotty/tools/dotc/ast/MainProxies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,13 @@ object MainProxies {
def mainProxy(mainFun: Symbol, paramAnnotations: ParameterAnnotationss, defaultValueSymbols: DefaultValueSymbols, docComment: Option[Comment])(using Context): List[TypeDef] = {
val mainAnnot = mainFun.getAnnotation(defn.MainAnnot).get
def pos = mainFun.sourcePos
val mainArgsName: TermName = nme.args
val cmdName: TermName = Names.termName("cmd")

val documentation = new Documentation(docComment)

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

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

/** () => value */
def unitToValue(value: Tree): Tree =
val anonName = nme.ANON_FUN
Expand All @@ -125,7 +121,7 @@ object MainProxies {
def createArgs(mt: MethodType, cmdName: TermName): List[(Tree, ValDef)] =
mt.paramInfos.zip(mt.paramNames).zipWithIndex.map {
case ((formal, paramName), n) =>
val argName = mainArgsName ++ n.toString
val argName = nme.args ++ n.toString

val isRepeated = formal.isRepeatedParam

Expand Down Expand Up @@ -213,7 +209,7 @@ object MainProxies {
TypeTree(),
Apply(
Select(instanciateAnnotation(mainAnnot), defn.MainAnnot_command.name),
Ident(mainArgsName) :: lit(mainFun.showName) :: lit(documentation.mainDoc) :: Nil
Ident(nme.args) :: lit(mainFun.showName) :: lit(documentation.mainDoc) :: Nil
)
)
var args: List[ValDef] = Nil
Expand Down Expand Up @@ -242,7 +238,7 @@ object MainProxies {

val run = Apply(Select(Ident(cmdName), defn.MainAnnotCommand_run.name), mainCall)
val body = Block(cmd :: args, run)
val mainArg = ValDef(mainArgsName, TypeTree(defn.ArrayType.appliedTo(defn.StringType)), EmptyTree)
val mainArg = ValDef(nme.args, TypeTree(defn.ArrayType.appliedTo(defn.StringType)), EmptyTree)
.withFlags(Param)
/** Replace typed `Ident`s that have been typed with a TypeSplice with the reference to the symbol.
* The annotations will be retype-checked in another scope that may not have the same imports.
Expand Down
1 change: 0 additions & 1 deletion library/src/scala/main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import annotation._
* displaying the help
*/
final class main(maxLineLength: Int) extends MainAnnotation:
self =>
import main._
import MainAnnotation._

Expand Down

0 comments on commit f1bc063

Please sign in to comment.