From c37185d3307e2b02e25e888fd44d5e8bba95aa1d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 21 Jul 2016 14:51:16 +0200 Subject: Fix #1401: Make sure all refs are forwarded Faced with recursive dependencies through self types, we might have to apply `normalizeToClassRefs` to a class P with a parent that is not yet initialized (witnessed by P's parents being Nil). In that case we should still execute forwardRefs on P, but we have to wait in a suspension until P is initialized. This avoids the problem raised in #1401. I am still not quite sure why forwardRefs is needed, but it seems that asSeenFrom alone is not enough to track the dependencies in this case. --- tests/pos/i1401.scala | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/pos/i1401.scala (limited to 'tests/pos/i1401.scala') diff --git a/tests/pos/i1401.scala b/tests/pos/i1401.scala new file mode 100644 index 000000000..140d78e7f --- /dev/null +++ b/tests/pos/i1401.scala @@ -0,0 +1,25 @@ +package i1401 + +trait Subtractable[A, +Repr <: Subtractable[A, Repr]] { + def -(elem: A): Repr +} + +trait BufferLike[BA, +This <: BufferLike[BA, This] with Buffer[BA]] + extends Subtractable[BA, This] +{ self : This => + + /* Without fix-#1401: + * + error: overriding method - in trait Subtractable of type (elem: A)This & i1401.Buffer[A]; + method - of type (elem: BA)This has incompatible type + def -(elem: BA): This + ^ + one error found + */ + def -(elem: BA): This +} + +trait Buffer[A] extends BufferLike[A, Buffer[A]] + + + -- cgit v1.2.3