Skip to content

Commit 472c047

Browse files
authored
Add test for StackOverflow question 68877939 (scala#21775)
https://stackoverflow.com/q/68877939/21927647 Answer to the question: > You were not doing anything wrong, this was an implementation limitation. > > Your example compiles successfully since Scala 3.4, thanks to the changes introduced in SIP-56 "Proper specification for match types" ([text](https://docs.scala-lang.org/sips/match-types-spec.html#:~:text=This%20SIP%20proposes%20a%20proper,the%20specification%20of%20the%20language.), [PR](scala#18262)).
2 parents b94160b + e546f07 commit 472c047

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/pos/so68877939.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
abstract class Quantity[A <: Quantity[A]]
2+
sealed trait UnitOfMeasure[A <: Quantity[A]]
3+
4+
class Time extends Quantity[Time]
5+
object Minutes extends UnitOfMeasure[Time]
6+
7+
class PowerRamp extends Quantity[PowerRamp]
8+
object KilowattsPerHour extends UnitOfMeasure[PowerRamp]
9+
10+
type Test[X <: UnitOfMeasure[?]] = X match
11+
case UnitOfMeasure[t] => t
12+
13+
@main def main =
14+
summon[Test[Minutes.type] =:= Time]
15+
summon[Test[KilowattsPerHour.type] =:= PowerRamp]

0 commit comments

Comments
 (0)