diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index d933e55a9823..5a3be6505715 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1988,7 +1988,7 @@ object Parsers { if isSimpleLiteral then SingletonTypeTree(simpleLiteral()) else if in.token == USCORE then - if ctx.settings.XkindProjector.value == "underscores" then + if ctx.settings.XkindProjector.value == "underscores" && !inMatchPattern then val start = in.skipToken() Ident(tpnme.USCOREkw).withSpan(Span(start, in.lastOffset, start)) else diff --git a/tests/pos/14952.scala b/tests/pos/14952.scala new file mode 100644 index 000000000000..350607b7ef77 --- /dev/null +++ b/tests/pos/14952.scala @@ -0,0 +1,9 @@ +//> using options -Xkind-projector:underscores + +import Tuple.* + +type LiftP[F[_], T] <: Tuple = + T match { + case _ *: _ => F[Head[T]] *: LiftP[F, Tail[T]] + case _ => EmptyTuple + } diff --git a/tests/pos/21400.scala b/tests/pos/21400.scala new file mode 100644 index 000000000000..6d1534703a00 --- /dev/null +++ b/tests/pos/21400.scala @@ -0,0 +1,7 @@ +//> using options -Xkind-projector:underscores + +import scala.compiletime.ops.int.S + +type IndexOf[T <: Tuple, E] <: Int = T match + case E *: _ => 0 + case _ *: es => 1 // S[IndexOf[es, E]] diff --git a/tests/pos/21400b.scala b/tests/pos/21400b.scala new file mode 100644 index 000000000000..9e8768d48261 --- /dev/null +++ b/tests/pos/21400b.scala @@ -0,0 +1,10 @@ +//> using options -Xkind-projector:underscores + +import scala.quoted.Type +import scala.quoted.Quotes + +def x[A](t: Type[A])(using Quotes): Boolean = t match + case '[_ *: _] => + true + case _ => + false