-
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.
Merge pull request #14525 from andrzejressel/no_sum_for_enum_case
Don't generate Mirror.Sum for simple enum cases
- Loading branch information
Showing
3 changed files
with
64 additions
and
1 deletion.
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,40 @@ | ||
import scala.util.NotGiven | ||
import scala.compiletime.* | ||
import scala.deriving.Mirror | ||
|
||
enum Color: | ||
case Red, Green, Blue | ||
end Color | ||
|
||
enum Bar: | ||
case A(i: Int) | ||
case B(b: Boolean) | ||
case C(s: String) | ||
|
||
object Singletons { | ||
object A | ||
object B | ||
} | ||
|
||
type SumOfK1[F[_]] = Mirror.Sum { type MirroredType[T] = F[T] } | ||
|
||
class refined extends scala.annotation.RefiningAnnotation | ||
|
||
object Test { | ||
|
||
def main(args: Array[String]): Unit = { | ||
summon[Mirror.ProductOf[Color]] // error | ||
summon[Mirror.SumOf[Color.Red.type]] // error | ||
summon[Mirror.SumOf[Color.Red.type | Color.Green.type]] // error | ||
summon[Mirror.SumOf[Bar.A | Bar.B]] // error | ||
summon[Mirror.SumOf[Singletons.A.type | Singletons.B.type]] // error | ||
summon[SumOfK1[[X] =>> Bar]] | ||
summon[SumOfK1[[X] =>> Bar.A | Bar.B]] // error | ||
summon[SumOfK1[[X] =>> (Bar.A | Bar.B) @refined]] // error | ||
object opaques { | ||
opaque type Query[X] = (Bar.A | Bar.B) @refined | ||
} | ||
summon[SumOfK1[opaques.Query]] // error | ||
summon[SumOfK1[[X] =>> (Bar.A @refined) | Bar.B]] // error | ||
} | ||
} |
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 @@ | ||
import scala.util.NotGiven | ||
import scala.compiletime.* | ||
import scala.deriving.Mirror | ||
|
||
enum Color: | ||
case Red, Green, Blue | ||
end Color | ||
|
||
object Test { | ||
|
||
def main(args: Array[String]): Unit = { | ||
summon[Mirror.Of[Color.Red.type]] | ||
summon[Mirror.Of[Color]] | ||
summon[Mirror.ProductOf[Color.Red.type]] | ||
summon[Mirror.SumOf[Color]] | ||
} | ||
} |