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
-
6
1
package dotty .tools
7
2
package dotc
8
3
package config
@@ -41,8 +36,10 @@ abstract class Platform {
41
36
/** The given symbol is a method with the right name and signature to be a runnable program. */
42
37
def isMainMethod (sym : SymDenotation )(implicit ctx : Context ): Boolean
43
38
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 =
46
43
sym.info.member(nme.main).hasAltWith {
47
44
case x : SymDenotation => isMainMethod(x)
48
45
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
230
230
231
231
allNonLocalClassesInSrc += cl
232
232
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.
234
236
_mainClasses += name
235
237
}
236
238
You can’t perform that action at this time.
0 commit comments