-
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.
Improve ConstraintHandling of SkolemTypes (#20175)
By retaining instantiated type vars in ApproximatingTypeMap when possible.
- Loading branch information
Showing
5 changed files
with
84 additions
and
2 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
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,27 @@ | ||
|
||
trait Summon[R, T <: R]: | ||
type Out | ||
object Summon: | ||
given [R, T <: R]: Summon[R, T] with | ||
type Out = R | ||
|
||
trait DFTypeAny | ||
trait DFBits[W <: Int] extends DFTypeAny | ||
class DFVal[+T <: DFTypeAny] | ||
type DFValAny = DFVal[DFTypeAny] | ||
type DFValOf[+T <: DFTypeAny] = DFVal[T] | ||
trait Candidate[R]: | ||
type OutW <: Int | ||
object Candidate: | ||
type Aux[R, O <: Int] = Candidate[R] { type OutW = O } | ||
given [W <: Int, R <: DFValOf[DFBits[W]]]: Candidate[R] with | ||
type OutW = W | ||
|
||
extension [L](lhs: L) def foo(using es: Summon[L, lhs.type]): Unit = ??? | ||
extension [L <: DFValAny](lhs: L)(using icL: Candidate[L]) def baz: DFValOf[DFBits[icL.OutW]] = ??? | ||
extension [L <: DFValAny, W <: Int](lhs: L)(using icL: Candidate.Aux[L, W]) | ||
def bazAux: DFValOf[DFBits[W]] = ??? | ||
|
||
val x = new DFVal[DFBits[4]] | ||
val works = x.bazAux.foo | ||
val fails = x.baz.foo |
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,17 @@ | ||
|
||
trait Wrap[W] | ||
|
||
trait IsWrapOfInt[R]: | ||
type Out <: Int | ||
given [W <: Int, R <: Wrap[W]]: IsWrapOfInt[R] with | ||
type Out = Int | ||
|
||
trait IsInt[U <: Int] | ||
given [U <: Int]: IsInt[U] = ??? | ||
|
||
extension [L](lhs: L) def get(using ev: IsWrapOfInt[L]): ev.Out = ??? | ||
extension (lhs: Int) def isInt(using IsInt[lhs.type]): Unit = ??? | ||
|
||
val x: Wrap[Int] = ??? | ||
val works = (x.get: Int).isInt | ||
val fails = x.get.isInt |
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,22 @@ | ||
|
||
trait Sub[R, T >: R] | ||
given [R, T >: R]: Sub[R, T] with {} | ||
|
||
trait Candidate[-R]: | ||
type OutP | ||
given [P]: Candidate[Option[P]] with | ||
type OutP = P | ||
|
||
extension [L](lhs: L) | ||
def ^^^[P](rhs: Option[P]) | ||
(using es: Sub[lhs.type, Any]) | ||
(using c: Candidate[L]) | ||
(using check: c.type <:< Any): Option[c.OutP] = ??? | ||
|
||
val x: Option[Boolean] = ??? | ||
|
||
val z1 = x ^^^ x // Ok | ||
val z2 = z1 ^^^ x // Ok | ||
val zz = ^^^[Option[Boolean]](x ^^^ x)(x) // Ok | ||
|
||
val zzz = x ^^^ x ^^^ x // Error before changes |