@@ -65,54 +65,8 @@ class DottyBackendInterface(val outputDirectory: AbstractFile, val superCallsMap
6565 if (found == null ) None else Some (found)
6666 }
6767
68- extension symExtensions on (sym : Symbol ) {
69-
70- def isInterface : Boolean = (sym.is(Flags .PureInterface )) || sym.is(Flags .Trait )
71-
72- def isStaticConstructor : Boolean = (sym.isStaticMember && sym.isClassConstructor) || (sym.name eq nme.STATIC_CONSTRUCTOR )
73-
74- def isStaticMember : Boolean = (sym ne NoSymbol ) &&
75- (sym.is(Flags .JavaStatic ) || sym.hasAnnotation(ctx.definitions.ScalaStaticAnnot ))
76- // guard against no sumbol cause this code is executed to select which call type(static\dynamic) to use to call array.clone
77-
78- /**
79- * True for module classes of modules that are top-level or owned only by objects. Module classes
80- * for such objects will get a MODULE$ flag and a corresponding static initializer.
81- */
82- def isStaticModuleClass : Boolean =
83- (sym.is(Flags .Module )) && {
84- // scalac uses atPickling here
85- // this would not work if modules are created after pickling
86- // for example by specialization
87- val original = toDenot(sym).initial
88- val validity = original.validFor
89- val shiftedContext = ctx.withPhase(validity.phaseId)
90- toDenot(sym)(shiftedContext).isStatic(shiftedContext)
91- }
92-
9368
9469
95- def originalLexicallyEnclosingClass : Symbol =
96- // used to populate the EnclosingMethod attribute.
97- // it is very tricky in presence of classes(and annonymous classes) defined inside supper calls.
98- if (sym.exists) {
99- val validity = toDenot(sym).initial.validFor
100- val shiftedContext = ctx.withPhase(validity.phaseId)
101- toDenot(sym)(shiftedContext).lexicallyEnclosingClass(shiftedContext)
102- } else NoSymbol
103-
104- /**
105- * True for module classes of package level objects. The backend will generate a mirror class for
106- * such objects.
107- */
108- def isTopLevelModuleClass : Boolean =
109- sym.is(Flags .ModuleClass ) &&
110- ctx.atPhase(ctx.flattenPhase) {
111- toDenot(sym).owner.is(Flags .PackageClass )
112- }
113-
114- }
115-
11670 object SelectBI extends DeconstructorCommon [tpd.Tree ] {
11771
11872 var desugared : tpd.Select = null
@@ -185,3 +139,54 @@ class DottyBackendInterface(val outputDirectory: AbstractFile, val superCallsMap
185139 }
186140
187141}
142+
143+ object DottyBackendInterface {
144+
145+ extension symExtensions on (sym : Symbol ) {
146+
147+ def isInterface (using Context ): Boolean = (sym.is(Flags .PureInterface )) || sym.is(Flags .Trait )
148+
149+ def isStaticConstructor (using Context ): Boolean = (sym.isStaticMember && sym.isClassConstructor) || (sym.name eq nme.STATIC_CONSTRUCTOR )
150+
151+ def isStaticMember (using Context ): Boolean = (sym ne NoSymbol ) &&
152+ (sym.is(Flags .JavaStatic ) || sym.hasAnnotation(ctx.definitions.ScalaStaticAnnot ))
153+ // guard against no sumbol cause this code is executed to select which call type(static\dynamic) to use to call array.clone
154+
155+ /**
156+ * True for module classes of modules that are top-level or owned only by objects. Module classes
157+ * for such objects will get a MODULE$ flag and a corresponding static initializer.
158+ */
159+ def isStaticModuleClass (using Context ): Boolean =
160+ (sym.is(Flags .Module )) && {
161+ // scalac uses atPickling here
162+ // this would not work if modules are created after pickling
163+ // for example by specialization
164+ val original = toDenot(sym).initial
165+ val validity = original.validFor
166+ val shiftedContext = ctx.withPhase(validity.phaseId)
167+ toDenot(sym)(shiftedContext).isStatic(shiftedContext)
168+ }
169+
170+
171+
172+ def originalLexicallyEnclosingClass (using Context ): Symbol =
173+ // used to populate the EnclosingMethod attribute.
174+ // it is very tricky in presence of classes(and annonymous classes) defined inside supper calls.
175+ if (sym.exists) {
176+ val validity = toDenot(sym).initial.validFor
177+ val shiftedContext = ctx.withPhase(validity.phaseId)
178+ toDenot(sym)(shiftedContext).lexicallyEnclosingClass(shiftedContext)
179+ } else NoSymbol
180+
181+ /**
182+ * True for module classes of package level objects. The backend will generate a mirror class for
183+ * such objects.
184+ */
185+ def isTopLevelModuleClass (using Context ): Boolean =
186+ sym.is(Flags .ModuleClass ) &&
187+ ctx.atPhase(ctx.flattenPhase) {
188+ toDenot(sym).owner.is(Flags .PackageClass )
189+ }
190+
191+ }
192+ }
0 commit comments