From 36b49497186b50febf865a556d338d109f9027a6 Mon Sep 17 00:00:00 2001 From: EnzeXing Date: Tue, 20 Aug 2024 14:23:36 -0400 Subject: [PATCH] Address comment --- compiler/src/dotty/tools/dotc/transform/init/Objects.scala | 5 ++++- tests/init-global/pos/cache-constructor.scala | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/transform/init/Objects.scala b/compiler/src/dotty/tools/dotc/transform/init/Objects.scala index 892cd3ce8b06..1050fbe85ef2 100644 --- a/compiler/src/dotty/tools/dotc/transform/init/Objects.scala +++ b/compiler/src/dotty/tools/dotc/transform/init/Objects.scala @@ -908,7 +908,10 @@ class Objects(using Context @constructorOnly): Bottom } - /** Handle new expression `new p.C(args)`. + /** + * Handle new expression `new p.C(args)`. + * The actual instance might be cached without running the constructor. + * See tests/init-global/pos/cache-constructor.scala * * @param outer The value for `p`. * @param klass The symbol of the class `C`. diff --git a/tests/init-global/pos/cache-constructor.scala b/tests/init-global/pos/cache-constructor.scala index f7af30f32516..87769fd5d78a 100644 --- a/tests/init-global/pos/cache-constructor.scala +++ b/tests/init-global/pos/cache-constructor.scala @@ -6,4 +6,3 @@ object A: val b2 = new Bar() val b3 = new Bar() b3.f = 1 - \ No newline at end of file