Skip to content

Commit e00caba

Browse files
nox213zielinsky
authored andcommitted
Make opaque types decomposable
1 parent 9f70200 commit e00caba

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,6 @@ object SpaceEngine {
724724
&& cls.isOneOf(AbstractOrTrait) // ignore sealed non-abstract classes
725725
&& !cls.hasAnonymousChild // can't name anonymous classes as counter-examples
726726
&& cls.children.nonEmpty // can't decompose without children
727-
&& !sym.isOpaqueAlias // can't instantiate subclasses to conform to an opaque type (i19275)
728727

729728
val ListOfNoType = List(NoType)
730729
val ListOfTypNoType = ListOfNoType.map(Typ(_, decomposed = true))

tests/pos/i22513.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
opaque type R[T] <: T = T
2+
3+
object Test {
4+
enum E:
5+
case A(a: Int)
6+
7+
val v: R[E] = ???
8+
v match
9+
case E.A(_) =>
10+
}
11+
12+
sealed trait Foo
13+
14+
case class FooA() extends Foo
15+
case class FooB() extends Foo
16+
17+
object O {
18+
opaque type OpaqueFoo <: Foo = Foo
19+
def fooB(): OpaqueFoo = FooB()
20+
}
21+
22+
@main def main =
23+
val p: O.OpaqueFoo = O.fooB()
24+
25+
p match
26+
case _: FooA => println("fooA")
27+
case _: FooB => println("fooB")

0 commit comments

Comments
 (0)