Skip to content

Commit d948982

Browse files
committed
Allow multidenotations with same signature
Instead of issuing a merge error, allow multi-denotations with alternatives that have the same signature. This does not work yet for unpickling.
1 parent 587945b commit d948982

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

compiler/src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ object Denotations {
407407
}
408408

409409
/** Try to merge single-denotations. */
410-
def mergeSingleDenot(denot1: SingleDenotation, denot2: SingleDenotation): SingleDenotation = {
410+
def mergeSingleDenot(denot1: SingleDenotation, denot2: SingleDenotation): Denotation = {
411411
val info1 = denot1.info
412412
val info2 = denot2.info
413413
val sym1 = denot1.symbol
@@ -465,9 +465,10 @@ object Denotations {
465465
preferSym(sym1, sym2) &&
466466
info1.overrides(info2, sym1.matchNullaryLoosely || sym2.matchNullaryLoosely, checkClassInfo = false)
467467

468-
def handleDoubleDef =
468+
def handleDoubleDef: Denotation =
469469
if (preferSym(sym1, sym2)) denot1
470470
else if (preferSym(sym2, sym1)) denot2
471+
else if sym1.exists then MultiDenotation(denot1, denot2)
471472
else doubleDefError(denot1, denot2, pre)
472473

473474
if (sym2Accessible && prefer(sym2, sym1, info2, info1)) denot2

compiler/test/dotc/pos-from-tasty.blacklist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ i7087.scala
1313
# Nullability
1414
nullable.scala
1515
notNull.scala
16+
17+
i9050.scala

compiler/test/dotc/pos-test-pickling.blacklist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ i7757.scala
4343

4444
# splice type tag dealiased in this reference
4545
i8651b.scala
46+
47+
i9050.scala

tests/neg/i1240b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ abstract class A[X] extends T[X] {
99
trait U[X] extends T[X] {
1010
abstract override def foo(x: X): X = super.foo(x)
1111
}
12-
object Test extends A[String] with U[String] // error: accidental override // error: merge error
12+
object Test extends A[String] with U[String] // error: accidental override

tests/pos/i9050.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
object Foo {
3+
val foo = scala.collection.mutable.ArrayBuffer.empty[Seq[Double]]
4+
val bar = Seq.empty[Double]
5+
foo.append(bar)
6+
}

0 commit comments

Comments
 (0)