File tree 2 files changed +4
-7
lines changed
compiler/src/dotty/tools/dotc
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
-
6
1
package dotty .tools
7
2
package dotc
8
3
package config
@@ -12,6 +7,7 @@ import core.Contexts._, core.Symbols._
12
7
import core .SymbolLoader
13
8
import core .SymDenotations .SymDenotation
14
9
import core .StdNames .nme
10
+ import core .Flags .Module
15
11
16
12
/** The platform dependent pieces of Global.
17
13
*/
@@ -44,7 +40,7 @@ abstract class Platform {
44
40
/** The given class has a main method. */
45
41
final def hasMainMethod (sym : Symbol )(implicit ctx : Context ): Boolean =
46
42
sym.info.member(nme.main).hasAltWith {
47
- case x : SymDenotation => isMainMethod(x)
43
+ case x : SymDenotation => isMainMethod(x) && (sym.is( Module ) || x.isStatic)
48
44
case _ => false
49
45
}
50
46
}
Original file line number Diff line number Diff line change @@ -230,7 +230,8 @@ 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 ) && ctx.platform.hasMainMethod(sym)) {
234
+ // If sym is an object, all main methods count, otherwise only @static ones count.
234
235
_mainClasses += name
235
236
}
236
237
You can’t perform that action at this time.
0 commit comments