From 7e3ca7686071b6a026105fd7962549d6cb126fa0 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 10 Jun 2018 15:42:59 +0200 Subject: [PATCH] Fix #4623: Don't check for repeated parents in refinement classes Refinement classes are just a temporary detour to get refinements. The restriction that the same parent cannot be extended twice does not hold for them. --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 3 ++- tests/pos/i4623.scala | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i4623.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 049ec5d4b5ea..49817e4e9ebc 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1491,7 +1491,8 @@ class Typer extends Namer def typedParent(tree: untpd.Tree): Tree = { var result = if (tree.isType) typedType(tree)(superCtx) else typedExpr(tree)(superCtx) val psym = result.tpe.typeSymbol - if (seenParents.contains(psym)) ctx.error(i"$psym is extended twice", tree.pos) + if (seenParents.contains(psym) && !cls.isRefinementClass) + ctx.error(i"$psym is extended twice", tree.pos) seenParents += psym if (tree.isType) { if (psym.is(Trait) && !cls.is(Trait) && !cls.superClass.isSubClass(psym)) diff --git a/tests/pos/i4623.scala b/tests/pos/i4623.scala new file mode 100644 index 000000000000..31e673a13643 --- /dev/null +++ b/tests/pos/i4623.scala @@ -0,0 +1,7 @@ +trait Test { + type A <: Any { type T } + type B <: Any { type T } + type C <: A with B { type T } + + type D <: List[A] with List[B] { type T } +}