Skip to content

Commit eb8e8ff

Browse files
committed
Move SymDenotation#proxy to SymbolLoader#proxy
It's only ever used on SymbolLoaders, and more importantly it means that a proxy to a SymbolLoader is now also a SymbolLoader which we'll use to enforce restrictions on which completers are allowed to set `privateWithin` in a later commit.
1 parent 85f0f4f commit eb8e8ff

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,13 +2155,6 @@ object SymDenotations {
21552155
private[this] var mySourceModuleFn: Context => Symbol = NoSymbolFn
21562156
private[this] var myModuleClassFn: Context => Symbol = NoSymbolFn
21572157

2158-
/** A proxy to this lazy type that keeps the complete operation
2159-
* but provides fresh slots for scope/sourceModule/moduleClass
2160-
*/
2161-
def proxy: LazyType = new LazyType {
2162-
override def complete(denot: SymDenotation)(implicit ctx: Context) = self.complete(denot)
2163-
}
2164-
21652158
/** The type parameters computed by the completer before completion has finished */
21662159
def completerTypeParams(sym: Symbol)(implicit ctx: Context): List[TypeParamInfo] =
21672160
if (sym.is(Touched)) Nil // return `Nil` instead of throwing a cyclic reference

compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ object SymbolLoaders {
200200
*/
201201
class PackageLoader(_sourceModule: TermSymbol, classPath: ClassPath)
202202
extends SymbolLoader {
203+
override def sourceFileOrNull: AbstractFile = null
203204
override def sourceModule(implicit ctx: Context): TermSymbol = _sourceModule
204205
def description(implicit ctx: Context): String = "package loader " + sourceModule.fullName
205206

@@ -302,18 +303,25 @@ object SymbolLoaders {
302303
/** A lazy type that completes itself by calling parameter doComplete.
303304
* Any linked modules/classes or module classes are also initialized.
304305
*/
305-
abstract class SymbolLoader extends LazyType {
306-
306+
abstract class SymbolLoader extends LazyType { self =>
307307
/** Load source or class file for `root`, return */
308308
def doComplete(root: SymDenotation)(implicit ctx: Context): Unit
309309

310-
def sourceFileOrNull: AbstractFile = null
310+
def sourceFileOrNull: AbstractFile
311311

312312
/** Description of the resource (ClassPath, AbstractFile)
313313
* being processed by this loader
314314
*/
315315
def description(implicit ctx: Context): String
316316

317+
/** A proxy to this loader that keeps the doComplete operation
318+
* but provides fresh slots for scope/sourceModule/moduleClass
319+
*/
320+
def proxy: SymbolLoader = new SymbolLoader {
321+
export self.{doComplete, sourceFileOrNull}
322+
def description(implicit ctx: Context): String = "proxy to ${self.description}"
323+
}
324+
317325
override def complete(root: SymDenotation)(implicit ctx: Context): Unit = {
318326
def signalError(ex: Exception): Unit = {
319327
if (ctx.debug) ex.printStackTrace()

0 commit comments

Comments
 (0)