File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 1- /* NSC -- new Scala compiler
2- * Copyright 2005-2012 LAMP/EPFL
3- * @author Paul Phillips
4- */
5-
61package dotty .tools
72package dotc
83package config
@@ -41,8 +36,10 @@ abstract class Platform {
4136 /** The given symbol is a method with the right name and signature to be a runnable program. */
4237 def isMainMethod (sym : SymDenotation )(implicit ctx : Context ): Boolean
4338
44- /** The given class has a main method. */
45- final def hasMainMethod (sym : Symbol )(implicit ctx : Context ): Boolean =
39+ /** The given class has a main method.
40+ * @param staticOnly only static main methods count
41+ */
42+ final def hasMainMethod (sym : Symbol , staticOnly : Boolean = false )(implicit ctx : Context ): Boolean =
4643 sym.info.member(nme.main).hasAltWith {
4744 case x : SymDenotation => isMainMethod(x)
4845 case _ => false
Original file line number Diff line number Diff line change @@ -230,7 +230,9 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
230230
231231 allNonLocalClassesInSrc += cl
232232
233- if (sym.isStatic && ctx.platform.hasMainMethod(sym)) {
233+ if (sym.isStatic && ! sym.is(Trait ) &&
234+ ctx.platform.hasMainMethod(sym, staticOnly = ! sym.is(Module ))) {
235+ // If sym is an object, all main methods count, otherwise only @static ones count.
234236 _mainClasses += name
235237 }
236238
You can’t perform that action at this time.
0 commit comments