File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1460,9 +1460,13 @@ class Typer extends Namer
14601460 ref
14611461 }
14621462
1463+ val seenParents = mutable.Set [Symbol ]()
1464+
14631465 def typedParent (tree : untpd.Tree ): Tree = {
14641466 var result = if (tree.isType) typedType(tree)(superCtx) else typedExpr(tree)(superCtx)
14651467 val psym = result.tpe.typeSymbol
1468+ if (seenParents.contains(psym)) ctx.error(i " $psym is extended twice " , tree.pos)
1469+ seenParents += psym
14661470 if (tree.isType) {
14671471 if (psym.is(Trait ) && ! cls.is(Trait ) && ! cls.superClass.isSubClass(psym))
14681472 result = maybeCall(result, psym, psym.primaryConstructor.info)
Original file line number Diff line number Diff line change 1+ object Test extends App {
2+ trait A [+ X ](val x : X )
3+ class B extends A (5 ) with A (" hello" ) // error: A is extended twice
4+
5+ def f (a : A [Int ]): Int = a match {
6+ case b : B => b.x
7+ case _ => 0
8+ }
9+
10+ f(new B )
11+ }
You can’t perform that action at this time.
0 commit comments