-
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.
Allow to reduce type member extractors when the member is a class.
- Loading branch information
Showing
4 changed files
with
57 additions
and
13 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,11 @@ | ||
-- [E172] Type Error: tests/neg/match-type-enumeration-value-hack.scala:11:40 ------------------------------------------ | ||
11 | summon[Suit#Value =:= EnumValue[Suit]] // error | ||
| ^ | ||
| Cannot prove that Suit#Value =:= EnumValue[Suit]. | ||
| | ||
| Note: a match type could not be fully reduced: | ||
| | ||
| trying to reduce EnumValue[Suit] | ||
| failed since selector Suit | ||
| does not match case EnumValueAux[t] => t | ||
| and cannot be shown to be disjoint from it either. |
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,12 @@ | ||
type EnumValueAux[A] = ({ type Value }) { type Value = A } | ||
|
||
type EnumValue[E <: Enumeration] = E match | ||
case EnumValueAux[t] => t | ||
|
||
// A class extending Enumeration does not yet define a concrete enumeration | ||
class Suit extends Enumeration: | ||
val Hearts, Diamonds, Clubs, Spades = Val() | ||
|
||
object Test: | ||
summon[Suit#Value =:= EnumValue[Suit]] // error | ||
end Test |
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,11 @@ | ||
type EnumValueAux[A] = ({ type Value }) { type Value = A } | ||
|
||
type EnumValue[E <: Enumeration] = E match | ||
case EnumValueAux[t] => t | ||
|
||
object Suit extends Enumeration: | ||
val Hearts, Diamonds, Clubs, Spades = Val() | ||
|
||
object Test: | ||
summon[Suit.Value =:= EnumValue[Suit.type]] | ||
end Test |