File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -319,7 +319,17 @@ class Definitions {
319319 def staticsMethodRef (name : PreName ) = ScalaStaticsModule .requiredMethodRef(name)
320320 def staticsMethod (name : PreName ) = ScalaStaticsModule .requiredMethod(name)
321321
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+
323333 def DottyPredefModule (implicit ctx : Context ) = DottyPredefModuleRef .symbol
324334
325335 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 {
3030class ImportInfo (symf : => Symbol , val selectors : List [untpd.Tree ],
3131 symNameOpt : Option [TermName ], val isRootImport : Boolean = false )(implicit ctx : Context ) {
3232
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 = _
3443
3544 /** The (TermRef) type of the qualifier of the import clause */
3645 def site (implicit ctx : Context ): Type = {
You can’t perform that action at this time.
0 commit comments