Skip to content

Commit fea778d

Browse files
authored
Merge pull request #13262 from dotty-staging/fix-9675
Fix #9675: Type _ in MT patterns with correct kind
2 parents 03c2cb1 + 6190702 commit fea778d

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,8 +1872,7 @@ class Typer extends Namer
18721872
arg match {
18731873
case untpd.WildcardTypeBoundsTree()
18741874
if tparam.paramInfo.isLambdaSub &&
1875-
tpt1.tpe.typeParamSymbols.nonEmpty &&
1876-
!ctx.mode.is(Mode.Pattern) =>
1875+
tpt1.tpe.typeParamSymbols.nonEmpty =>
18771876
// An unbounded `_` automatically adapts to type parameter bounds. This means:
18781877
// If we have wildcard application C[?], where `C` is a class replace
18791878
// with C[? >: L <: H] where `L` and `H` are the bounds of the corresponding

tests/pos/9675.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import scala.compiletime.ops.int.S
2+
3+
sealed trait TList
4+
sealed trait TNil extends TList
5+
sealed trait ++:[H[_], T <: TList] extends TList
6+
7+
type IndexOf[H[_], T <: TList] <: Int = T match
8+
case H ++: _ => 0
9+
case _ ++: t => S[IndexOf[H, t]]
10+
11+
// compiles fine
12+
val a = summon[ValueOf[IndexOf[List, List ++: Option ++: TNil]]].value
13+
14+
// causes an error
15+
val b = summon[ValueOf[IndexOf[List, Option ++: List ++: TNil]]].value
16+
17+
object T extends App:
18+
println(a)

0 commit comments

Comments
 (0)