forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework MatchType recursion in collectParts (scala#19867)
- Loading branch information
Showing
3 changed files
with
41 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
trait ThingWithPart { type Part } | ||
type PartField[A] = ThingWithPart { type Part = A } | ||
type ExtractPart[B] = B match { case PartField[a] => a } | ||
|
||
trait TC[C] | ||
object TC: | ||
def tcForOptionPart[D](implicit tc: TC[ExtractPart[D]]): TC[Option[ExtractPart[D]]] = new {} | ||
|
||
class Value | ||
object Value: | ||
implicit val tcValue: TC[Value] = new {} | ||
|
||
class ValuePartHolder extends ThingWithPart { type Part = Value } | ||
|
||
class Test: | ||
def t1: Unit = | ||
val tc = TC.tcForOptionPart[ValuePartHolder] |
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,23 @@ | ||
sealed trait DFTypeAny | ||
|
||
sealed trait DFTuple[T <: NonEmptyTuple] extends DFTypeAny | ||
|
||
sealed trait DFBit extends DFTypeAny | ||
|
||
sealed trait DFValOf[T] | ||
|
||
type Of[T] <: DFTypeAny = T match | ||
case DFTypeAny => T & DFTypeAny | ||
case Product => FromProduct[T] | ||
|
||
type JUSTVAL[T] = DFValOf[Of[T]] | ||
|
||
type FromProduct[T <: Product] <: DFTypeAny = T match | ||
case NonEmptyTuple => DFTuple[Tuple.Map[T, JUSTVAL]] | ||
|
||
trait Width2[T] | ||
|
||
object Width2: | ||
inline given [T]: Width2[T] = new Width2[T] {} | ||
|
||
val x = summon[Width2[Of[(DFBit, DFBit)]]] |