From 0f33d4d93ad80660b1a43f6d5a14e4a9044e79f5 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 19 Aug 2020 17:02:29 +0200 Subject: [PATCH] Don't cache given aliases to `this` A given alias given Foo = this does not need to be cached in a lazy val since `this` is an immutable reference. --- .../src/dotty/tools/dotc/transform/CacheAliasImplicits.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/src/dotty/tools/dotc/transform/CacheAliasImplicits.scala b/compiler/src/dotty/tools/dotc/transform/CacheAliasImplicits.scala index c4cfe83ae4bb..ad2acb7f7c47 100644 --- a/compiler/src/dotty/tools/dotc/transform/CacheAliasImplicits.scala +++ b/compiler/src/dotty/tools/dotc/transform/CacheAliasImplicits.scala @@ -56,6 +56,7 @@ class CacheAliasImplicits extends MiniPhase with IdentityDenotTransformer { this if rhsTpe.isStable => false case rhsTpe @ TermRef(pre: ThisType, _) if rhsTpe.isStable && pre.cls == sym.owner.enclosingClass => false + case rhsTpe: ThisType => false case _ => true } case _ => false