diff --git a/compiler/src/dotty/tools/dotc/config/Platform.scala b/compiler/src/dotty/tools/dotc/config/Platform.scala index 71e0d9cd107c..0dfbc060b6a6 100644 --- a/compiler/src/dotty/tools/dotc/config/Platform.scala +++ b/compiler/src/dotty/tools/dotc/config/Platform.scala @@ -1,8 +1,3 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2012 LAMP/EPFL - * @author Paul Phillips - */ - package dotty.tools package dotc package config @@ -12,6 +7,7 @@ import core.Contexts._, core.Symbols._ import core.SymbolLoader import core.SymDenotations.SymDenotation import core.StdNames.nme +import core.Flags.Module /** The platform dependent pieces of Global. */ @@ -44,7 +40,7 @@ abstract class Platform { /** The given class has a main method. */ final def hasMainMethod(sym: Symbol)(implicit ctx: Context): Boolean = sym.info.member(nme.main).hasAltWith { - case x: SymDenotation => isMainMethod(x) + case x: SymDenotation => isMainMethod(x) && (sym.is(Module) || x.isStatic) case _ => false } } diff --git a/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala b/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala index e9bf617a913f..cd3ff9ec6249 100644 --- a/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala +++ b/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala @@ -230,7 +230,8 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder allNonLocalClassesInSrc += cl - if (sym.isStatic && ctx.platform.hasMainMethod(sym)) { + if (sym.isStatic && !sym.is(Trait) && ctx.platform.hasMainMethod(sym)) { + // If sym is an object, all main methods count, otherwise only @static ones count. _mainClasses += name }