aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/Contexts.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-02-17 11:03:37 +0100
committerMartin Odersky <odersky@gmail.com>2017-02-17 11:17:17 +0100
commit9f26d32db25824f75e5c5b2c2314352c42b074c1 (patch)
tree97ac0e5dc62b19f89d1fc4a07339e2adb472cc4b /compiler/src/dotty/tools/dotc/core/Contexts.scala
parent6df672c7e7be65d7be1cd6524c610aed4f35178c (diff)
downloaddotty-9f26d32db25824f75e5c5b2c2314352c42b074c1.tar.gz
dotty-9f26d32db25824f75e5c5b2c2314352c42b074c1.tar.bz2
dotty-9f26d32db25824f75e5c5b2c2314352c42b074c1.zip
Treat implicit by-name arguments as lazy values
With the previous rules, the two test cases produce a diverging implicit expansion. We avoid this by creating for every implicit by-name argument of type T a lazy implicit value of the same type. The implicit value is visible for all nested implicit searches of by-name arguments. That way, we tie the knot and obtain a recursive lazy value instead of a diverging expansion.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/Contexts.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/core/Contexts.scala3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Contexts.scala b/compiler/src/dotty/tools/dotc/core/Contexts.scala
index 29629e505..6b7be12be 100644
--- a/compiler/src/dotty/tools/dotc/core/Contexts.scala
+++ b/compiler/src/dotty/tools/dotc/core/Contexts.scala
@@ -202,7 +202,7 @@ object Contexts {
private[core] var pendingMemberSearches: List[Name] = Nil
/** The new implicit references that are introduced by this scope */
- private var implicitsCache: ContextualImplicits = null
+ protected var implicitsCache: ContextualImplicits = null
def implicits: ContextualImplicits = {
if (implicitsCache == null )
implicitsCache = {
@@ -469,6 +469,7 @@ object Contexts {
def setTypeAssigner(typeAssigner: TypeAssigner): this.type = { this.typeAssigner = typeAssigner; this }
def setTyper(typer: Typer): this.type = { this.scope = typer.scope; setTypeAssigner(typer) }
def setImportInfo(importInfo: ImportInfo): this.type = { this.importInfo = importInfo; this }
+ def setImplicits(implicits: ContextualImplicits): this.type = { this.implicitsCache = implicits; this }
def setRunInfo(runInfo: RunInfo): this.type = { this.runInfo = runInfo; this }
def setDiagnostics(diagnostics: Option[StringBuilder]): this.type = { this.diagnostics = diagnostics; this }
def setGadt(gadt: GADTMap): this.type = { this.gadt = gadt; this }