File tree Expand file tree Collapse file tree 2 files changed +4
-7
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +4
-7
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
@@ -12,6 +7,7 @@ import core.Contexts._, core.Symbols._
127import core .SymbolLoader
138import core .SymDenotations .SymDenotation
149import core .StdNames .nme
10+ import core .Flags .Module
1511
1612/** The platform dependent pieces of Global.
1713 */
@@ -44,7 +40,7 @@ abstract class Platform {
4440 /** The given class has a main method. */
4541 final def hasMainMethod (sym : Symbol )(implicit ctx : Context ): Boolean =
4642 sym.info.member(nme.main).hasAltWith {
47- case x : SymDenotation => isMainMethod(x)
43+ case x : SymDenotation => isMainMethod(x) && (sym.is( Module ) || x.isStatic)
4844 case _ => false
4945 }
5046}
Original file line number Diff line number Diff line change @@ -230,7 +230,8 @@ 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 ) && ctx.platform.hasMainMethod(sym)) {
234+ // If sym is an object, all main methods count, otherwise only @static ones count.
234235 _mainClasses += name
235236 }
236237
You can’t perform that action at this time.
0 commit comments