@@ -16,6 +16,7 @@ import transform.SymUtils._
16
16
import Contexts .Context
17
17
import Names .{Name , TermName }
18
18
import NameKinds .{InlineAccessorName , InlineBinderName , InlineScrutineeName , MemoCacheName }
19
+ import NameOps ._
19
20
import ProtoTypes .selectionProto
20
21
import SymDenotations .SymDenotation
21
22
import Inferencing .fullyDefinedType
@@ -407,7 +408,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
407
408
408
409
/** The expansion of `memo(op)` where `op: T` is:
409
410
*
410
- * { if (memo$N == null) memo$N = op ; $memo.asInstanceOf[T] }
411
+ * { if (memo$N == null) memo$N_=(op) ; $memo.asInstanceOf[T] }
411
412
*
412
413
* This creates as a side effect a memo cache symbol $memo$N` of type `T | Null`.
413
414
* TODO: Restrict this to non-null types, once nullability checking is in.
@@ -425,10 +426,17 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
425
426
else Synthetic | Mutable | Private | Local ,
426
427
info = OrType (argType, defn.NullType ),
427
428
coord = call.span)
429
+ val memoSetter = ctx.newSymbol(
430
+ owner = cacheOwner,
431
+ name = memoVar.name.setterName,
432
+ flags = memoVar.flags | Method | Accessor ,
433
+ info = MethodType (argType :: Nil , defn.UnitType ),
434
+ coord = call.span
435
+ )
428
436
val memoRef = ref(memoVar).withSpan(call.span)
429
437
val cond = If (
430
438
memoRef.select(defn.Any_== ).appliedTo(Literal (Constant (null ))),
431
- memoRef .becomes(callValueArgss.head.head),
439
+ ref(memoSetter).withSpan(call.span) .becomes(callValueArgss.head.head),
432
440
Literal (Constant (())))
433
441
val expr = memoRef.cast(argType)
434
442
Block (cond :: Nil , expr)
0 commit comments