Skip to content

Commit 1b196c9

Browse files
committed
Move methods
1 parent c1c8e45 commit 1b196c9

File tree

3 files changed

+32
-41
lines changed

3 files changed

+32
-41
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,19 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
434434
annot.tree.tpe.typeSymbol.getAnnotation(AnnotationRetentionAttr).
435435
flatMap(_.argumentConstant(0).map(_.symbolValue)).getOrElse(AnnotationRetentionClassAttr)
436436

437+
private def assocsFromApply(tree: Tree): List[(Name, Tree)] = {
438+
tree match {
439+
case Block(_, expr) => assocsFromApply(expr)
440+
case Apply(fun, args) =>
441+
fun.tpe.widen match {
442+
case MethodType(names) =>
443+
(names zip args).filter {
444+
case (_, t: tpd.Ident) if (t.tpe.normalizedPrefix eq NoPrefix) => false
445+
case _ => true
446+
}
447+
}
448+
}
449+
}
437450
} // end of trait BCAnnotGen
438451

439452
trait BCJGenSigGen {

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import scala.annotation.threadUnsafe
77

88
import dotty.tools.dotc.core.Flags
99
import dotty.tools.dotc.core.Symbols._
10+
import dotty.tools.dotc.core.Phases.Phase
1011
import dotty.tools.dotc.transform.SymUtils._
1112

1213
/**
@@ -125,7 +126,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
125126
// The lambdalift phase lifts all nested classes to the enclosing class, so if we collect
126127
// member classes right after lambdalift, we obtain all nested classes, including local and
127128
// anonymous ones.
128-
val nestedClasses = symHelper(classSym).nestedClasses
129+
val nestedClasses = getNestedClasses(classSym)
129130

130131
// If this is a top-level class, and it has a companion object, the member classes of the
131132
// companion are added as members of the class. For example:
@@ -143,7 +144,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
143144
val companionModuleMembers = {
144145
// phase travel to exitingPickler: this makes sure that memberClassesOf only sees member classes,
145146
// not local classes of the companion module (E in the example) that were lifted by lambdalift.
146-
if (classSym.linkedClass.isTopLevelModuleClass) /*exitingPickler*/ symHelper(classSym.linkedClass).memberClasses
147+
if (classSym.linkedClass.isTopLevelModuleClass) /*exitingPickler*/ getMemberClasses(classSym.linkedClass)
147148
else Nil
148149
}
149150

@@ -175,6 +176,22 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
175176
classBType
176177
}
177178

179+
/** For currently compiled classes: All locally defined classes including local classes.
180+
* The empty list for classes that are not currently compiled.
181+
*/
182+
private def getNestedClasses(sym: Symbol): List[Symbol] = definedClasses(sym, ctx.flattenPhase)
183+
184+
/** For currently compiled classes: All classes that are declared as members of this class
185+
* (but not inherited ones). The empty list for classes that are not currently compiled.
186+
*/
187+
private def getMemberClasses(sym: Symbol): List[Symbol] = definedClasses(sym, ctx.lambdaLiftPhase)
188+
189+
private def definedClasses(sym: Symbol, phase: Phase) =
190+
if (sym.isDefinedInCurrentRun)
191+
ctx.atPhase(phase) {
192+
toDenot(sym).info.decls.filter(_.isClass)
193+
}
194+
else Nil
178195

179196
private def buildNestedInfo(innerClassSym: Symbol): Option[NestedInfo] = {
180197
assert(innerClassSym.isClass, s"Cannot build NestedInfo for non-class symbol $innerClassSym")

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -192,21 +192,6 @@ class DottyBackendInterface(val outputDirectory: AbstractFile, val superCallsMap
192192
None
193193
}
194194

195-
196-
def assocsFromApply(tree: Tree): List[(Name, Tree)] = {
197-
tree match {
198-
case Block(_, expr) => assocsFromApply(expr)
199-
case Apply(fun, args) =>
200-
fun.tpe.widen match {
201-
case MethodType(names) =>
202-
(names zip args).filter {
203-
case (_, t: tpd.Ident) if (t.tpe.normalizedPrefix eq NoPrefix) => false
204-
case _ => true
205-
}
206-
}
207-
}
208-
}
209-
210195
extension symExtensions on (sym: Symbol) {
211196

212197
def isInterface: Boolean = (sym.is(Flags.PureInterface)) || sym.is(Flags.Trait)
@@ -255,30 +240,6 @@ class DottyBackendInterface(val outputDirectory: AbstractFile, val superCallsMap
255240

256241
}
257242

258-
def symHelper(sym: Symbol): SymbolHelper = new SymbolHelper(sym)
259-
260-
class SymbolHelper(sym: Symbol) {
261-
262-
/** For currently compiled classes: All locally defined classes including local classes.
263-
* The empty list for classes that are not currently compiled.
264-
265-
*/
266-
def nestedClasses: List[Symbol] = definedClasses(ctx.flattenPhase)
267-
268-
/** For currently compiled classes: All classes that are declared as members of this class
269-
* (but not inherited ones). The empty list for classes that are not currently compiled.
270-
*/
271-
def memberClasses: List[Symbol] = definedClasses(ctx.lambdaLiftPhase)
272-
273-
private def definedClasses(phase: Phase) =
274-
if (sym.isDefinedInCurrentRun)
275-
ctx.atPhase(phase) {
276-
toDenot(sym).info.decls.filter(_.isClass)
277-
}
278-
else Nil
279-
280-
}
281-
282243
object SelectBI extends DeconstructorCommon[tpd.Tree] {
283244

284245
var desugared: tpd.Select = null

0 commit comments

Comments
 (0)