Skip to content

Commit 7044a61

Browse files
committed
Restore changes for ExtractAPI. Move miniphase to transformers batch.
1 parent f118982 commit 7044a61

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class Compiler {
4242
List(new semanticdb.ExtractSemanticDB) :: // Extract info into .semanticdb files
4343
List(new PostTyper) :: // Additional checks and cleanups after type checking
4444
List(new sjs.PrepJSInterop) :: // Additional checks and transformations for Scala.js (Scala.js only)
45-
List(new CollectEntryPoints) :: // Collect all entry points and save them in the context
4645
List(new sbt.ExtractAPI) :: // Sends a representation of the API of classes to sbt via callbacks
4746
List(new SetRootTree) :: // Set the `rootTreeOrProvider` on class symbols
4847
Nil
@@ -131,6 +130,7 @@ class Compiler {
131130
new RestoreScopes, // Repair scopes rendered invalid by moving definitions in prior phases of the group
132131
new SelectStatic, // get rid of selects that would be compiled into GetStatic
133132
new sjs.JUnitBootstrappers, // Generate JUnit-specific bootstrapper classes for Scala.js (not enabled by default)
133+
new CollectEntryPoints, // Collect all entry points and save them in the context
134134
new CollectSuperCalls, // Find classes that are called with super
135135
new RepeatableAnnotations) :: // Aggregate repeatable annotations
136136
Nil

compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ExtractAPI extends Phase {
6666

6767
val apiTraverser = new ExtractAPICollector
6868
val classes = apiTraverser.apiSource(unit.tpdTree)
69-
val mainClasses = ctx.entryPoints.toSet
69+
val mainClasses = apiTraverser.mainClasses
7070

7171
if (ctx.settings.YdumpSbtInc.value) {
7272
// Append to existing file that should have been created by ExtractDependencies
@@ -144,6 +144,7 @@ private class ExtractAPICollector(using Context) extends ThunkHolder {
144144
private val refinedTypeCache = new mutable.HashMap[(api.Type, api.Definition), api.Structure]
145145

146146
private val allNonLocalClassesInSrc = new mutable.HashSet[xsbti.api.ClassLike]
147+
private val _mainClasses = new mutable.HashSet[String]
147148

148149
private object Constants {
149150
val emptyStringArray = Array[String]()
@@ -194,6 +195,11 @@ private class ExtractAPICollector(using Context) extends ThunkHolder {
194195
def apiClass(sym: ClassSymbol): api.ClassLikeDef =
195196
classLikeCache.getOrElseUpdate(sym, computeClass(sym))
196197

198+
def mainClasses: Set[String] = {
199+
forceThunks()
200+
_mainClasses.toSet
201+
}
202+
197203
private def computeClass(sym: ClassSymbol): api.ClassLikeDef = {
198204
import xsbti.api.{DefinitionType => dt}
199205
val defType =
@@ -228,6 +234,11 @@ private class ExtractAPICollector(using Context) extends ThunkHolder {
228234

229235
allNonLocalClassesInSrc += cl
230236

237+
if (sym.isStatic && !sym.is(Trait) && ctx.platform.hasMainMethod(sym)) {
238+
// If sym is an object, all main methods count, otherwise only @static ones count.
239+
_mainClasses += name
240+
}
241+
231242
api.ClassLikeDef.of(name, acc, modifiers, anns, tparams, defType)
232243
}
233244

0 commit comments

Comments
 (0)