File tree 2 files changed +15
-0
lines changed
compiler/src/dotty/tools/dotc/typer
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
1460
1460
ref
1461
1461
}
1462
1462
1463
+ val seenParents = mutable.Set [Symbol ]()
1464
+
1463
1465
def typedParent (tree : untpd.Tree ): Tree = {
1464
1466
var result = if (tree.isType) typedType(tree)(superCtx) else typedExpr(tree)(superCtx)
1465
1467
val psym = result.tpe.typeSymbol
1468
+ if (seenParents.contains(psym)) ctx.error(i " $psym is extended twice " , tree.pos)
1469
+ seenParents += psym
1466
1470
if (tree.isType) {
1467
1471
if (psym.is(Trait ) && ! cls.is(Trait ) && ! cls.superClass.isSubClass(psym))
1468
1472
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