Skip to content

Commit 30731c1

Browse files
committed
Fix regression in exhausitivity of HK types
1 parent dde69ce commit 30731c1

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ object SpaceEngine {
347347
case pat: Ident if isBackquoted(pat) =>
348348
Typ(pat.tpe, decomposed = false)
349349

350+
case pat: Ident if pat.name == nme.WILDCARD =>
351+
Typ(erase(pat.tpe.stripAnnots.widenSkolem), decomposed = false)
352+
350353
case Ident(_) | Select(_, _) =>
351354
Typ(erase(pat.tpe.stripAnnots.widenSkolem, isValue = true), decomposed = false)
352355

tests/pos/i17230.min1.scala

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// scalac: -Werror
2+
trait Foo:
3+
type Bar[_]
4+
5+
object Foo:
6+
type Aux[B[_]] = Foo { type Bar[A] = B[A] }
7+
8+
class Test:
9+
def t1[B[_]](self: Option[Foo.Aux[B]]) = self match
10+
case Some(_) => 1
11+
case None => 2
12+
13+
def t2[B[_]](self: Option[Foo.Aux[B]]) = self match
14+
case Some(f) => 1
15+
case None => 2

tests/pos/i17230.orig.scala

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// scalac: -Werror
2+
import scala.util.*
3+
4+
trait Transaction {
5+
type State[_]
6+
}
7+
object Transaction {
8+
type of[S[_]] = Transaction { type State[A] = S[A] }
9+
}
10+
trait DynamicScope[State[_]]
11+
12+
case class ScopeSearch[State[_]](self: Either[Transaction.of[State], DynamicScope[State]]) {
13+
14+
def embedTransaction[T](f: Transaction.of[State] => T): T =
15+
self match {
16+
case Left(integrated) => ???
17+
case Right(ds) => ???
18+
}
19+
}
20+

0 commit comments

Comments
 (0)