Skip to content
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

Backport "Cover patterns using reflect.TypeTest in isMatchTypeShaped" to LTS #21002

Merged
merged 1 commit into from
Jul 4, 2024
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
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
// check `pat` here and throw away the result.
val gadtCtx: Context = ctx.fresh.setFreshGADTBounds
val pat1 = typedPattern(pat, selType)(using gadtCtx)
val Typed(_, tpt) = tpd.unbind(tpd.unsplice(pat1)): @unchecked
val tpt = tpd.unbind(tpd.unsplice(pat1)) match
case Typed(_, tpt) => tpt
case UnApply(fun, _, p1 :: _) if fun.symbol == defn.TypeTest_unapply => p1
instantiateMatchTypeProto(pat1, pt) match {
case defn.MatchCase(patternTp, _) => tpt.tpe frozen_=:= patternTp
case _ => false
Expand Down
8 changes: 8 additions & 0 deletions tests/pos/i19692.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

trait UsingTypeTest[B](using reflect.TypeTest[Int, B]):

type M[U <: Int] = U match
case B => String

def m(t: Int): M[Int] = t match
case _: B => "hello"