Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect warning when object contains multiple main methods #6896

Closed
scabug opened this issue Dec 30, 2012 · 3 comments
Closed

Incorrect warning when object contains multiple main methods #6896

scabug opened this issue Dec 30, 2012 · 3 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Dec 30, 2012

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 found

However it will will run successfully:

scala TooManyMains
Hello, World!
@scabug
Copy link
Author

scabug commented Dec 30, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6896?orig=1
Reporter: @eengbrec
Affected Versions: 2.10.0-RC5
Attachments:

  • mains.scala (created on Dec 30, 2012 9:48:03 PM UTC, 171 bytes)

@scabug
Copy link
Author

scabug commented Dec 31, 2012

@paulp said:
scala/scala#1835

@scabug
Copy link
Author

scabug commented Jun 6, 2013

@retronym said:
This was merged in 2.10.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants