From ea8d6d938b38194f9591b81425e552216a73ae77 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 30 Sep 2023 13:18:33 +0200 Subject: [PATCH] Handle case where select target has no source --- compiler/src/dotty/tools/dotc/transform/init/Objects.scala | 7 +++++-- 1 file changed, 5 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 836218f302bc..2f6b47ac100b 100644 --- a/compiler/src/dotty/tools/dotc/transform/init/Objects.scala +++ b/compiler/src/dotty/tools/dotc/transform/init/Objects.scala @@ -766,8 +766,11 @@ object Objects: val target = if needResolve then resolve(ref.klass, field) else field if target.is(Flags.Lazy) then given Env.Data = Env.emptyEnv(target.owner.asInstanceOf[ClassSymbol].primaryConstructor) - val rhs = target.defTree.asInstanceOf[ValDef].rhs - eval(rhs, ref, target.owner.asClass, cacheResult = true) + if target.hasSource then + val rhs = target.defTree.asInstanceOf[ValDef].rhs + eval(rhs, ref, target.owner.asClass, cacheResult = true) + else + Bottom else if target.exists then if target.isOneOf(Flags.Mutable) then if ref.hasVar(target) then