diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2017-01-10 22:36:30 +0100 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2017-01-28 19:12:19 +0100 |
commit | dc5ba9d2ba31b2fe27f5b967c9fb800bc9210a93 (patch) | |
tree | 3fe1a54e734a97fc6a999a695a7e1141cff6d460 /compiler/src/dotty/tools/dotc/core/Definitions.scala | |
parent | 779c96bef04d81048f91135b386bd7f37fcf1f20 (diff) | |
download | dotty-dc5ba9d2ba31b2fe27f5b967c9fb800bc9210a93.tar.gz dotty-dc5ba9d2ba31b2fe27f5b967c9fb800bc9210a93.tar.bz2 dotty-dc5ba9d2ba31b2fe27f5b967c9fb800bc9210a93.zip |
Workaroud #1856: recursively calling a lazy val works differently in Dotty
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/Definitions.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/Definitions.scala | 12 |
1 files changed, 11 insertions, 1 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) |