Skip to content

Fix #9675: Type _ in MT patterns with correct kind #13262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)