aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/Symbols.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/Symbols.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/Symbols.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/core/Symbols.scala4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala
index 5d0dd2123..c5e064478 100644
--- a/compiler/src/dotty/tools/dotc/core/Symbols.scala
+++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala
@@ -258,6 +258,10 @@ trait Symbols { this: Context =>
def newDefaultConstructor(cls: ClassSymbol) =
newConstructor(cls, EmptyFlags, Nil, Nil)
+ /** Create a synthetic lazy implicit value */
+ def newLazyImplicit(info: Type) =
+ newSymbol(owner, freshName(nme.LAZY_IMPLICIT_PREFIX).toTermName, Lazy, info)
+
/** Create a symbol representing a selftype declaration for class `cls`. */
def newSelfSym(cls: ClassSymbol, name: TermName = nme.WILDCARD, selfInfo: Type = NoType): TermSymbol =
ctx.newSymbol(cls, name, SelfSymFlags, selfInfo orElse cls.classInfo.selfType, coord = cls.coord)