Skip to content

Commit 504adde

Browse files
committed
Make method an extension
1 parent 266a7c5 commit 504adde

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
143143
val companionModuleMembers = {
144144
// phase travel to exitingPickler: this makes sure that memberClassesOf only sees member classes,
145145
// not local classes of the companion module (E in the example) that were lifted by lambdalift.
146-
if (symHelper(classSym.linkedClass).isTopLevelModuleClass) /*exitingPickler*/ symHelper(classSym.linkedClass).memberClasses
146+
if (classSym.linkedClass.isTopLevelModuleClass) /*exitingPickler*/ symHelper(classSym.linkedClass).memberClasses
147147
else Nil
148148
}
149149

@@ -205,7 +205,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
205205
if (!str.isEmpty && str.last == '$') str.take(str.length - 1) else str
206206
// Java compatibility. See the big comment in BTypes that summarizes the InnerClass spec.
207207
val outerNameModule =
208-
if (symHelper(innerClassSym.originalOwner.originalLexicallyEnclosingClass).isTopLevelModuleClass) dropModule(outerName)
208+
if (innerClassSym.originalOwner.originalLexicallyEnclosingClass.isTopLevelModuleClass) dropModule(outerName)
209209
else outerName
210210
Some(outerNameModule.toString)
211211
}
@@ -256,7 +256,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
256256
final def javaFlags(sym: Symbol): Int = {
257257

258258

259-
val privateFlag = sym.is(Flags.Private) || (sym.isPrimaryConstructor && symHelper(sym.owner).isTopLevelModuleClass)
259+
val privateFlag = sym.is(Flags.Private) || (sym.isPrimaryConstructor && sym.owner.isTopLevelModuleClass)
260260

261261
val finalFlag = sym.is(Flags.Final) && !toDenot(sym).isClassConstructor && !(sym.is(Flags.Mutable)) && !(sym.enclosingClass.is(Flags.Trait))
262262

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -241,19 +241,22 @@ class DottyBackendInterface(val outputDirectory: AbstractFile, val superCallsMap
241241
toDenot(sym)(shiftedContext).lexicallyEnclosingClass(shiftedContext)
242242
} else NoSymbol
243243

244+
/**
245+
* True for module classes of package level objects. The backend will generate a mirror class for
246+
* such objects.
247+
*/
248+
def isTopLevelModuleClass: Boolean =
249+
sym.is(Flags.ModuleClass) &&
250+
ctx.atPhase(ctx.flattenPhase) {
251+
toDenot(sym).owner.is(Flags.PackageClass)
252+
}
253+
244254
}
245255

246256
def symHelper(sym: Symbol): SymbolHelper = new SymbolHelper(sym)
247257

248258
class SymbolHelper(sym: Symbol) {
249259

250-
// tests
251-
252-
253-
// navigation
254-
255-
// members
256-
257260
/** For currently compiled classes: All locally defined classes including local classes.
258261
* The empty list for classes that are not currently compiled.
259262
@@ -272,15 +275,6 @@ class DottyBackendInterface(val outputDirectory: AbstractFile, val superCallsMap
272275
}
273276
else Nil
274277

275-
/**
276-
* True for module classes of package level objects. The backend will generate a mirror class for
277-
* such objects.
278-
*/
279-
def isTopLevelModuleClass: Boolean = sym.is(Flags.ModuleClass) &&
280-
ctx.atPhase(ctx.flattenPhase) {
281-
toDenot(sym).owner.is(Flags.PackageClass)
282-
}
283-
284278
}
285279

286280
object SelectBI extends DeconstructorCommon[tpd.Tree] {

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ object GenBCode {
7070
}
7171

7272
class GenBCodePipeline(val int: DottyBackendInterface)(implicit ctx: Context) extends BCodeSyncAndTry {
73+
import int.symExtensions
7374

7475
private var tree: Tree = _
7576

@@ -203,7 +204,7 @@ class GenBCodePipeline(val int: DottyBackendInterface)(implicit ctx: Context) ex
203204

204205
// -------------- mirror class, if needed --------------
205206
val mirrorC =
206-
if (int.symHelper(claszSymbol).isTopLevelModuleClass) {
207+
if (claszSymbol.isTopLevelModuleClass) {
207208
if (claszSymbol.companionClass == NoSymbol) {
208209
mirrorCodeGen.genMirrorClass(claszSymbol, cunit)
209210
} else {

0 commit comments

Comments
 (0)