Skip to content

Commit d7dd68f

Browse files
committed
adds initialize and fullyInitialize
As per Paul’s request, this commit introduces facilities to force initialization of reflection artifacts. Sure, initialize (actually, even fullyInitialize) is silently performed by Symbol.typeSignature for runtime reflection, but people don’t have to know about that.
1 parent 9582eb5 commit d7dd68f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/reflect/scala/reflect/api/Internals.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,23 @@ trait Internals { self: Universe =>
233233
*/
234234
def deSkolemize(symbol: Symbol): Symbol
235235

236+
/** Forces all outstanding completers associated with this symbol.
237+
* After this call returns, the symbol becomes immutable and thread-safe.
238+
*/
239+
def initialize(symbol: Symbol): symbol.type
240+
241+
/** Calls [[initialize]] on the owner and all the value and type parameters of the symbol.
242+
*/
243+
def fullyInitialize(symbol: Symbol): symbol.type
244+
245+
/** Calls [[initialize]] on all the value and type parameters of the type.
246+
*/
247+
def fullyInitialize(tp: Type): tp.type
248+
249+
/** Calls [[initialize]] on all the symbols that the scope consists of.
250+
*/
251+
def fullyInitialize(scope: Scope): scope.type
252+
236253
/** A creator for `ThisType` types.
237254
*/
238255
def thisType(sym: Symbol): Type

src/reflect/scala/reflect/internal/Internals.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ trait Internals extends api.Internals {
7474
def isErroneous(symbol: Symbol): Boolean = symbol.isErroneous
7575
def isSkolem(symbol: Symbol): Boolean = symbol.isSkolem
7676
def deSkolemize(symbol: Symbol): Symbol = symbol.deSkolemize
77+
def initialize(symbol: Symbol): symbol.type = symbol.initialize
78+
def fullyInitialize(symbol: Symbol): symbol.type = definitions.fullyInitializeSymbol(symbol).asInstanceOf[symbol.type]
79+
def fullyInitialize(tp: Type): tp.type = definitions.fullyInitializeType(tp).asInstanceOf[tp.type]
80+
def fullyInitialize(scope: Scope): scope.type = definitions.fullyInitializeScope(scope).asInstanceOf[scope.type]
7781
def attachments(symbol: Symbol): Attachments { type Pos = Position } = symbol.attachments
7882
def updateAttachment[T: ClassTag](symbol: Symbol, attachment: T): symbol.type = symbol.updateAttachment(attachment)
7983
def removeAttachment[T: ClassTag](symbol: Symbol): symbol.type = symbol.removeAttachment[T]

0 commit comments

Comments
 (0)