From b3e006fc72bd7c489b62716bc89d4f6f390d79a2 Mon Sep 17 00:00:00 2001 From: odersky Date: Fri, 25 Mar 2022 11:39:25 +0100 Subject: [PATCH] Don't force LazyRefs when computing DepStatus Fixes #14771 --- compiler/src/dotty/tools/dotc/core/Types.scala | 3 +++ tests/pos/i14771.scala | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/pos/i14771.scala diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 24acce54cc4b..14ffa150818b 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -3635,6 +3635,9 @@ object Types { if ann.refersToParamOf(thisLambdaType) then TrueDeps else compute(status, parent, theAcc) case _: ThisType | _: BoundType | NoPrefix => status + case t: LazyRef => + if t.completed then compute(status, t.ref, theAcc) + else Unknown case _ => (if theAcc != null then theAcc else DepAcc()).foldOver(status, tp) compute(initial, tp, null) diff --git a/tests/pos/i14771.scala b/tests/pos/i14771.scala new file mode 100644 index 000000000000..31b12602fd00 --- /dev/null +++ b/tests/pos/i14771.scala @@ -0,0 +1,13 @@ +trait Layouts: + type Layout <: { + def withName(name: String): Layout + } + val l: Layout + +val ls = new Layouts: + class Layout17: + def withName(name: String): Layout17 = this + type Layout = Layout17 + val l = Layout17() + +def test = ls.l