diff options
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/Definitions.scala | 12 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/typer/ImportInfo.scala | 11 |
2 files changed, 21 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index 134b31519..0aeb28d36 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -319,7 +319,17 @@ class Definitions { def staticsMethodRef(name: PreName) = ScalaStaticsModule.requiredMethodRef(name) def staticsMethod(name: PreName) = ScalaStaticsModule.requiredMethod(name) - lazy val DottyPredefModuleRef = ctx.requiredModuleRef("dotty.DottyPredef") + // Dotty deviation: we cannot use a lazy val here because lazy vals in dotty + // will return "null" when called recursively, see #1856. + def DottyPredefModuleRef = { + if (myDottyPredefModuleRef == null) { + myDottyPredefModuleRef = ctx.requiredModuleRef("dotty.DottyPredef") + assert(myDottyPredefModuleRef != null) + } + myDottyPredefModuleRef + } + private[this] var myDottyPredefModuleRef: TermRef = _ + def DottyPredefModule(implicit ctx: Context) = DottyPredefModuleRef.symbol def Predef_eqAny(implicit ctx: Context) = DottyPredefModule.requiredMethod(nme.eqAny) diff --git a/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala b/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala index a5657890e..f7efb2ac2 100644 --- a/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala +++ b/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala @@ -30,7 +30,16 @@ object ImportInfo { class ImportInfo(symf: => Symbol, val selectors: List[untpd.Tree], symNameOpt: Option[TermName], val isRootImport: Boolean = false)(implicit ctx: Context) { - lazy val sym = symf + // Dotty deviation: we cannot use a lazy val here for the same reason + // that we cannot use one for `DottyPredefModuleRef`. + def sym = { + if (mySym == null) { + mySym = symf + assert(mySym != null) + } + mySym + } + private[this] var mySym: Symbol = _ /** The (TermRef) type of the qualifier of the import clause */ def site(implicit ctx: Context): Type = { |