-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Description
When an object contains multiple methods named main, including one with a valid type signature for the "true" main method, the compiler issues a warning indicating that the object contains no such method.
Here's an example:
object TooManyMains {
def main(args: Array[String]): Unit = {
println("Hello, World!")
}
def main(a: Int, b: Int) = ???
def main(s: String, n: String) = ???
} scalac mains.scala
mains.scala:1: warning: TooManyMains has a main method with parameter type Array[String], but TooManyMains will not be a runnable program.
Reason: main method must have exact signature (Array[String])Unit
object TooManyMains {
^
one warning foundHowever it will will run successfully:
scala TooManyMains
Hello, World!