cvogt / cbt

CBT - fun, fast, intuitive, compositional, statically checked builds written in Scala
Other
488 stars 60 forks source link

Classes with non-trivial constructors were made to be not considered as possible main classes #587

Closed buzden closed 6 years ago

buzden commented 6 years ago

Possible fix for #585. Classes with non-public or parameterized contructors were made to be not searched by the main class searcher. This leads to

And, oh, I changed the signature of the typeStaticMethod, but I hope I made it more correct (since, as far as I can see, you use -OrFail suffix for those methods you are expecting to be easily failing).

buzden commented 6 years ago

Also, I suggest to add something like the following as a test.

object A { // Nice main class.
  def main(args: Array[String]): Unit = println("Hello, normal object!")
}

class X private { // Should not be considered as a main class.
  def main(args: Array[String]): Unit = println("Hello, private parameterless constructor!")
}

class Y(z: Int) { // Should not be considered as a main class.
  def main(args: Array[String]): Unit = println("Hello, parameterized constructor!")
}

class Z { // Okay as a main class for cbt.
  def main(args: Array[String]): Unit = println("Hello, public parameterless constructor!")
}

It is expected that (having this, for instance, in a single and only file of a project) cbt run does not fail and suggests you to run either A or Z as a main-class.

cvogt commented 6 years ago

Could you give an example of what this is fixing? Maybe including the code and call that trigger it, the problem you are seeing and what you are expecting to see instead?

buzden commented 6 years ago

Classes X and Y from above are examples of the situation when their existence in a project leads to simple failing of the cbt when trying to do cbt run.

cvogt commented 6 years ago

ah, sorry. forgot to read the related ticket.

cvogt commented 6 years ago

ah, great. LGTM.