File tree 2 files changed +21
-2
lines changed
compiler/src/dotty/tools/dotc
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -319,7 +319,17 @@ class Definitions {
319
319
def staticsMethodRef (name : PreName ) = ScalaStaticsModule .requiredMethodRef(name)
320
320
def staticsMethod (name : PreName ) = ScalaStaticsModule .requiredMethod(name)
321
321
322
- lazy val DottyPredefModuleRef = ctx.requiredModuleRef(" dotty.DottyPredef" )
322
+ // Dotty deviation: we cannot use a lazy val here because lazy vals in dotty
323
+ // will return "null" when called recursively, see #1856.
324
+ def DottyPredefModuleRef = {
325
+ if (_DottyPredefModuleRef == null ) {
326
+ _DottyPredefModuleRef = ctx.requiredModuleRef(" dotty.DottyPredef" )
327
+ assert(_DottyPredefModuleRef != null )
328
+ }
329
+ _DottyPredefModuleRef
330
+ }
331
+ private [this ] var _DottyPredefModuleRef : TermRef = _
332
+
323
333
def DottyPredefModule (implicit ctx : Context ) = DottyPredefModuleRef .symbol
324
334
325
335
def Predef_eqAny (implicit ctx : Context ) = DottyPredefModule .requiredMethod(nme.eqAny)
Original file line number Diff line number Diff line change @@ -30,7 +30,16 @@ object ImportInfo {
30
30
class ImportInfo (symf : => Symbol , val selectors : List [untpd.Tree ],
31
31
symNameOpt : Option [TermName ], val isRootImport : Boolean = false )(implicit ctx : Context ) {
32
32
33
- lazy val sym = symf
33
+ // Dotty deviation: we cannot use a lazy val here for the same reason
34
+ // that we cannot use one for `DottyPredefModuleRef`.
35
+ def sym = {
36
+ if (_sym == null ) {
37
+ _sym = symf
38
+ assert(_sym != null )
39
+ }
40
+ _sym
41
+ }
42
+ private [this ] var _sym : Symbol = _
34
43
35
44
/** The (TermRef) type of the qualifier of the import clause */
36
45
def site (implicit ctx : Context ): Type = {
You can’t perform that action at this time.
0 commit comments