Skip to content

Commit

Permalink
Fix scala#9675: Type _ in MT patterns with correct kind
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBlanvillain committed Aug 6, 2021
1 parent 03c2cb1 commit 057af51
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1872,8 +1872,7 @@ class Typer extends Namer
arg match {
case untpd.WildcardTypeBoundsTree()
if tparam.paramInfo.isLambdaSub &&
tpt1.tpe.typeParamSymbols.nonEmpty &&
!ctx.mode.is(Mode.Pattern) =>
tpt1.tpe.typeParamSymbols.nonEmpty =>
// An unbounded `_` automatically adapts to type parameter bounds. This means:
// If we have wildcard application C[?], where `C` is a class replace
// with C[? >: L <: H] where `L` and `H` are the bounds of the corresponding
Expand Down
18 changes: 18 additions & 0 deletions tests/pos/9675.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import scala.compiletime.S

sealed trait TList
sealed trait TNil extends TList
sealed trait ++:[H[_], T <: TList] extends TList

type IndexOf[H[_], T <: TList] <: Int = T match
case H ++: _ => 0
case _ ++: t => S[IndexOf[H, t]]

// compiles fine
val a = summon[ValueOf[IndexOf[List, List ++: Option ++: TNil]]].value

// causes an error
val b = summon[ValueOf[IndexOf[List, Option ++: List ++: TNil]]].value

object T extends App:
println(a)

0 comments on commit 057af51

Please sign in to comment.