Skip to content

Commit

Permalink
Cover patterns using reflet.TypeTest in isMatchTypeShaped
Browse files Browse the repository at this point in the history
[Cherry-picked 0942eef]
  • Loading branch information
EugeneFlesselle authored and WojciechMazur committed Jul 3, 2024
1 parent 4a8ab90 commit 44253cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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"

0 comments on commit 44253cc

Please sign in to comment.