Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1698,9 +1698,10 @@ object Types {
finally ctx.typerState.ephemeral |= savedEphemeral
}

private def disambiguate(d: Denotation)(implicit ctx: Context): Denotation = {
val sig = currentSignature
//if (ctx.isAfterTyper) println(i"overloaded $this / $d / sig = $sig") // DEBUG
private def disambiguate(d: Denotation)(implicit ctx: Context): Denotation =
disambiguate(d, currentSignature)

private def disambiguate(d: Denotation, sig: Signature)(implicit ctx: Context): Denotation =
if (sig != null)
d.atSignature(sig, relaxed = !ctx.erasedTypes) match {
case d1: SingleDenotation => d1
Expand All @@ -1711,7 +1712,6 @@ object Types {
}
}
else d
}

private def memberDenot(name: Name, allowPrivate: Boolean)(implicit ctx: Context): Denotation = {
var d = memberDenot(prefix, name, allowPrivate)
Expand Down Expand Up @@ -1974,12 +1974,10 @@ object Types {
def reload(): NamedType = {
val allowPrivate = !lastSymbol.exists || lastSymbol.is(Private) && prefix.classSymbol == this.prefix.classSymbol
var d = memberDenot(prefix, name, allowPrivate)
if (d.isOverloaded && lastSymbol.exists) {
val targetSig =
if (lastSymbol.signature == Signature.NotAMethod) Signature.NotAMethod
else lastSymbol.asSeenFrom(prefix).signature
d = d.atSignature(targetSig, relaxed = !ctx.erasedTypes)
}
if (d.isOverloaded && lastSymbol.exists)
d = disambiguate(d,
if (lastSymbol.signature == Signature.NotAMethod) Signature.NotAMethod
else lastSymbol.asSeenFrom(prefix).signature)
NamedType(prefix, name, d)
}
if (prefix eq this.prefix) this
Expand Down
15 changes: 15 additions & 0 deletions tests/pos/i3636.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
trait Iterable[A] {
def concat[B >: A](that: Iterable[B]): Iterable[B] = ???
@`inline` final def ++ [B >: A](that: Iterable[B]): Iterable[B] = concat(that)
}

class BitSet extends Iterable[Int] {
def concat(that: Iterable[Int]): BitSet = ???
@`inline` final def ++ (that: Iterable[Int]): BitSet = concat(that)
}

class Test {
def test(x: BitSet, y: Iterable[Int]): Unit = {
val foo = x ++ y
}
}