-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`resolveOverloaded1` starts with `narrowMostSpecific(candidates)` which compares the alternatives based on the 1st argument list. If more than one result if found, we can continue with the 2nd argument list. But we do so with the original candidates, rather than with the result of `narrowMostSpecific`. This can lead to choosing an alternative which is not the most specific, by now disregarding the 1st argument list. In i120053, the 1st pass correctly eliminated the 3rd `def ^^^`, but could not resolve between the 1st two (having the same argument list). The 2nd pass then disregarded this and restarted the comparison based on the 2nd argument list alone, which incorrectly yielded the 3rd option. The change is simply using the initial result of `narrowMostSpecific` in the recursive resolution based on subsequent argument lists. I'm not sure however if the same changes should apply to the rest of the cases attempting further narrowing ?
- Loading branch information
1 parent
c8c3bde
commit 946401c
Showing
5 changed files
with
84 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,4 +117,5 @@ i7445b.scala | |
|
||
# more aggresive reduce projection makes a difference | ||
i15525.scala | ||
i20053.scala | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
|
||
trait Summon[R, T <: R]: | ||
type Out | ||
object Summon: | ||
given [R, T <: R]: Summon[R, T] with | ||
type Out = R | ||
|
||
sealed class Modifier[+A, +P] | ||
type ModifierAny = Modifier[Any, Any] | ||
sealed trait ISCONST[T <: Boolean] | ||
type CONST = ISCONST[true] | ||
|
||
trait DFTypeAny | ||
trait DFBits[W <: Int] extends DFTypeAny | ||
trait DFVal[+T <: DFTypeAny, +M <: ModifierAny] | ||
type DFValAny = DFVal[DFTypeAny, ModifierAny] | ||
type DFValTP[+T <: DFTypeAny, +P] = DFVal[T, Modifier[Any, P]] | ||
type DFConstOf[+T <: DFTypeAny] = DFVal[T, Modifier[Any, CONST]] | ||
|
||
trait Candidate[R]: | ||
type OutW <: Int | ||
type OutP | ||
object Candidate: | ||
given [W <: Int, P, R <: DFValTP[DFBits[W], P]]: Candidate[R] with | ||
type OutW = W | ||
type OutP = P | ||
|
||
extension [L <: DFValAny](lhs: L)(using icL: Candidate[L]) | ||
def ^^^[R](rhs: R)(using | ||
icR: Candidate[R] | ||
): DFValTP[DFBits[icL.OutW], icL.OutP | icR.OutP] = ??? | ||
def ^^^ : Unit = ??? | ||
extension [L](lhs: L) | ||
def ^^^[RW <: Int, RP]( | ||
rhs: DFValTP[DFBits[RW], RP] | ||
)(using es: Summon[L, lhs.type])(using | ||
c: Candidate[L] | ||
)(using check: c.OutW =:= c.OutW): DFValTP[DFBits[c.OutW], c.OutP | RP] = ??? | ||
|
||
val x: DFConstOf[DFBits[8]] = ??? | ||
val zzz = x ^^^ x ^^^ x | ||
|
||
|
||
object Minimized: | ||
trait DFVal[+T <: Int, +P] | ||
|
||
trait Summon[R, T <: R] | ||
given [R, T <: R]: Summon[R, T] with {} | ||
|
||
trait Candidate[R]: | ||
type OutW <: Int | ||
type OutP | ||
given [W <: Int, P, R <: DFVal[W, P]]: Candidate[R] with | ||
type OutW = W | ||
type OutP = P | ||
|
||
extension [L <: DFVal[Int, Any]](lhs: L)(using icL: Candidate[L]) | ||
def ^^^[R](rhs: R) | ||
(using icR: Candidate[R]) | ||
: DFVal[icL.OutW, icL.OutP | icR.OutP] = ??? | ||
def ^^^ : Unit = ??? | ||
|
||
extension [L](lhs: L) | ||
def ^^^[RW <: Int, RP](rhs: DFVal[RW, RP]) | ||
(using es: Summon[L, lhs.type]) | ||
(using c: Candidate[L]) | ||
(using check: c.OutW =:= c.OutW) | ||
: DFVal[c.OutW, c.OutP | RP] = ??? | ||
|
||
val x: DFVal[8, true] = ??? | ||
val z1 = x ^^^ x // Ok | ||
val z2 = z1 ^^^ x // Ok | ||
val zzz = x ^^^ x ^^^ x // Error before changes | ||
|
||
/* Before the changes, when `def ^^^ : Unit = ???` is present, | ||
* all of z1, z2, zzz attempt to use the last `def ^^^`, | ||
* despite it being less specific than the 1st one. | ||
*/ | ||
end Minimized |