diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 6728cab6f3d0..906d4e561f95 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -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 diff --git a/tests/pos/9675.scala b/tests/pos/9675.scala new file mode 100644 index 000000000000..63f01cf73a2f --- /dev/null +++ b/tests/pos/9675.scala @@ -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)