Skip to content

Commit

Permalink
Merge pull request #13262 from dotty-staging/fix-9675
Browse files Browse the repository at this point in the history
Fix #9675: Type _ in MT patterns with correct kind
  • Loading branch information
odersky authored Aug 6, 2021
2 parents 03c2cb1 + 6190702 commit fea778d
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.ops.int.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 fea778d

Please sign in to comment.